Skip to Content

v\:*

o\:*

w\:*

.shape

<![endif]><![if gte mso 9]><![endif]><![if !mso]> classid=”clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D” id=ieooui>

st1\:*

<!–

/* Font Definitions */

@font-face

     {font-family:”Arial monospaced for SAP”;

     mso-font-alt:”Lucida Sans Typewriter”;

     mso-font-charset:0;

     mso-generic-font-family:modern;

     mso-font-pitch:fixed;

     mso-font-signature:3 0 0 0 1 0;}

/* Style Definitions */

p.MsoNormal, li.MsoNormal, div.MsoNormal

     {mso-style-parent:””;

     margin:0in;

     margin-bottom:.0001pt;

     mso-pagination:widow-orphan;

     

     font-family:”Times New Roman”;

     mso-fareast-font-family:”Times New Roman”;

     EN-AU;

     mso-fareast-language:EN-AU;}

span.SpellE

     {mso-style-name:””;

     mso-spl-e:yes;}

span.GramE

     {mso-style-name:””;

     mso-gram-e:yes;}

@page Section1

     

div.Section1

     

–>

</style>
<!–[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
     {mso-style-name:”Table Normal”;
     mso-tstyle-rowband-size:0;
     mso-tstyle-colband-size:0;
     mso-style-noshow:yes;
     mso-style-parent:””;
     mso-padding-alt:0in 5.4pt 0in 5.4pt;
     mso-para-margin:0in;
     mso-para-margin-bottom:.0001pt;
     mso-pagination:widow-orphan;
     font-size:10.0pt;
     font-family:”Times New Roman”;}
</style>

<![endif]><![if gte mso 9]><![endif]><![if gte mso 9]>

image

</v:shape><![endif]–><![if !vml]>!https://weblogs.sdn.sap.com/weblogs/images/42513/UserexitScreen1.jpg|src=https://weblogs.sdn.sap.com/weblogs/images/42513/UserexitScreen1.jpg|shapes=_x0000_i1025!<![endif]></p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal> lang=EN-AU Now, neither of
these structures contain the sales organisation field which we need, so how do
we get to it?   If we debug the
userexit and have a look at the call stack (refer to screen
shot) we can see that the SAPMV45A program (sales order entry module pool) is
loaded.</p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal align=center style=’text-align:center’> lang=EN-AU><!–[if gte vml 1]><v:shape
id=”_x0000_i1026″ type=”#_x0000_t75″ style=’width:3in;height:214.5pt’>

image

</v:shape><![endif]–><![if !vml]>!https://weblogs.sdn.sap.com/weblogs/images/42513/UserexitScreen2.JPG|width=288 height=286
v: |src=https://weblogs.sdn.sap.com/weblogs/images/42513/UserexitScreen2.JPG|shapes=_x0000_i1026!<![endif]></p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal> lang=EN-AU And from
experience, we happen to know that the VBAK structure is delcared in SAPMV45A and that it contains the field VKORG.
  But, is it populated at the time that this
userexit is called?   We
can check this in debug by referring to the program / variable name directly in
the field viewer (see screenshot below).</p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal align=center style=’text-align:center’> lang=EN-AU><!–[if gte vml 1]><v:shape
id=”_x0000_i1027″ type=”#_x0000_t75″ style=’width:225pt;height:314.25pt’>

image

</v:shape><![endif]–><![if !vml]>!https://weblogs.sdn.sap.com/weblogs/images/42513/UserexitScreen3.JPG|width=300 height=419
v: |src=https://weblogs.sdn.sap.com/weblogs/images/42513/UserexitScreen3.JPG|shapes=_x0000_i1027!<![endif]></p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal> lang=EN-AU So, now having
confirmed that the data we need is accessible in another program, we need to
access it from our  userexit.
 To do this we implement the following code:</p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:blue’>* Data declarations</p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:black’>
  CONSTANTS:  c_
vbak (14) type c value
‘(SAPMV45A)VBAK’.</p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:black’> </p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:black’>
  FIELD-SYMBOLS: < fs_vbak>
type  vbak.</p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:black’> </p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:blue’>* Now we assign the
field symbol to point to the VBAK structure which</p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:blue’>* is in SAPMV45A</p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:black’>
   ASSIGN ( c_vbak)
to < fs_vbak>.</p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:black’> </p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:blue’>* Now we can
perform coding based on the values in  vbak</p>

<p class=MsoNormal> lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:black’>
  IF < fs_vbak>-
vkorg = ‘FR01′. lang=EN-AU
9.0pt;</p>

<p class=MsoNormal> lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi- </p>

<p class=MsoNormal style=’mso-layout-grid-align:none;text-autospace:none’>
lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-font-family:”Arial monospaced for SAP”;color:blue’>*
  Switch on  lang=EN-AU
9.0pt;font-family:”Arial monospaced for SAP”;mso-bidi-font-family:
“Arial monospaced for SAP”;color:blue’>APO lang=EN-AU
9.0pt;font-family:”Arial monospaced for SAP”;mso-bidi-font-family:
“Arial monospaced for SAP”;color:blue’> Light</p>

<p class=MsoNormal> lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-     .</p>

<p class=MsoNormal> lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-     .</p>

<p class=MsoNormal> lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-     .</p>

<p class=MsoNormal> lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi- </p>

<p class=MsoNormal> lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”;
mso-bidi-  
ENDIF.</p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal> lang=EN-AU And that’s all
there is to it!   We can now use our <
fs_vbak> field symbol to access any of the data from
VBAK.   Of course this technique can also be
used to access any global data that is populated in other programs as we need
it.   </p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal> <b style=’mso-bidi-font-weight:normal’>
lang=EN-AU 14.0pt’>Wrapup</b><b
style=’mso-bidi-font-weight:normal’> lang=EN-AU 14.0pt’></b></p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal> lang=EN-AU I like this
technique because it delivers long on functionality (it dramatically increases
the scope of what you can do in  userexits without
changing the standard programs) whilst being fairly simple to implement.
  I should add one cautionary note, however as,
as with a lot of commands which grant you a high degree of power, the following comments are included in the SAP help:</p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal> lang=EN-AU 9.0pt’>“
lang=EN-AU 9.0pt;color:navy’>(Warning: This
option is for internal use by specialists only. Incompatible changes or
developments may occur at any time without prior notice)”
lang=EN-AU 9.0pt’></p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal> lang=EN-AU From a practical
point of view, though, I have been using this since 4.0B (I think) and have
encountered no problems so far.</p>

<p class=MsoNormal> lang=EN-AU  </p>

<p class=MsoNormal> lang=EN-AU> </p>

</div>

</body>

</html>

To report this post you need to login first.

20 Comments

You must be Logged on to comment or reply to a post.

    1. Brad Williams Post author
      Oops!,

      I hope others can see them.  This is the first time that I have posted and wasn’t too sure that I’d done it right.

      I have checked on two different PCs and it seems to work ok for me?

      Thanks for the comment.

      Brad

      (0) 
    1. Brad Williams Post author
      Hi Scott,

      Thought I’d distract people from the woeful text by the nice shiny colours! 🙂

      Actually, not sure why they turned out yellow, the quality suffers a bit too.  I promise to do better on my next one (maybe I wont use Word as my HTML editor).

      Brad

      (0) 
  1. Deepak Bhalla
    Hi Brad,

    It is really an intresting article.

    Is it possible to access full internal table using this method or can access just an workarea?

    Regards,
    Deepak

    (0) 
  2. Ofer Even-Tsur
    Hi Brad,

    I’ve been using your technique successfully on several user exits- both for variables and for internal tables. Thanks a lot for this Weblog! It was very helpful!

    This technique seems to fail on one specific machine, which happens to be a Unicode machine. The assign command for the field symbol is failing with sy-subrc=4. Can anyone else confirm this?

    (0) 
    1. Brad Williams Post author
      Hi Ofer,

      We are using this technique on an ECC 5.0 Unicode system.

      It works with no problems.

      Perhaps, its worth double checking the variable is really accessible and that the field symbol is correctly typed.

      Cheers,

      Brad

      (0) 
      1. Brad Williams Post author
        BTW – Looks like the blog has been nuked.  Does anyone have any ideas how I can clean it up?

        Bear in mind my HTML skills are strictly confined to the “Save-as” option in MS Word.

        Brad

        (0) 
      2. Ofer Even-Tsur
        Hi Brad,

        Thanks for your help! Indeed I was in the wrong…

        Yeah it looks like the site data is corrupted. Wish I knew how to fix it…

        Best regards,
        Ofer

        (0) 
  3. Anonymous
    Thanks Brad. This information is proving to be very helpful.

    However, do you know of a way to interrogate the list of programs in memory? If you know, it would be a great addition to this lesson, because when trying to use the ASSIGN statement for a variable in a program that is not loaded in memory, you get a GETWA_NOT_ASSIGNED runtime error.

    Cheers,

    Martin

    (0) 
    1. Brad Williams Post author
      Hi Martin,

      I have never had to interrogate the list of programs in memory, although a quick scan in SE37 reveals the function module SYSTEM_CALLSTACK which looks to be excatly what you are after.

      However, the runtime error you are describing should only be encountered when you use the “LOCAL COPY OF” option of the ASSIGN command.  If you just use the basic ASSIGN command, and you try to ASSIGN to a variable of a program that has not been loaded, then you get a non-zero sy-subrc rather than a runtime error.

      Hope that helps.

      Cheers,

      Brad

      (0) 
  4. Peter Van Avermaet
    Very useful!

    I have a case of a user-exit called by function. The variable I am trying to get at is not really a variable, but one of the parameters of the function. What would be the syntax in that case?

    What’s worse, it is a ‘tables’ argument.
    (SAPLFUGRNME)PARAM[]
    does not work.

    Even worse, this is an update function, so looking for the caller of my function does not help much.

    (0) 
  5. rachana santoshwar
    Hi Brad,

    i have a querry where i want to know that the data in shipping tab needs to be changed as per customer requirement . but since it’s value is not able to seen in user exit, so ur comment will help me .

    But for this let me know that the value of KUNNR which is to be changed has to be declared with respect to which program name .

    the coding goes like this

    CONSTANTS : NAME(200) TYPE C VALUE ‘(SAPMM06E)PTV[]’.
    FIELD-SYMBOLS: .
    ASSIGN (NAME) TO
    .

    but i am not sure that is it SAPMM06E or SAPLMEGUI.

    Ur input on this will be of great help.

    (0) 
  6. K. H. Nabar
    HI,

      I used this technique for 4.7.Its working fine.
    But its not working for 4.0b.

    I have one field in function module as a parameter.

    Inside that function module, there is a user exit.

    In user exit i want to access that parameter.
    I used (main program name of mainfunctionmodule)variable name.

    Its not working.Its giving dump message.

    Could you suggest on this point.Pls.

    (0) 
  7. Matus Lojan
    Hello,

    what’s wrong with this site?  I see plenty of html tags in the text, it looks like this:

    *******************************
    lang=EN-AU Using field symbols and the ( program_name ) field _name functionality of the dynamic ASSIGN statement, we can access data from other programs that are loaded into memory.   This looks something like:

    lang=EN-AU 

    lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”; mso-bidi-CONSTANTS: c_program_ variable (17) TYPE C VALUE ‘(program)variable’.

    lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”; mso-bidi-

    lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”; mso-bidi-FIELD-SYMBOLS:<fs_symbol> style=’mso-tab-count:2′>        TYPE VBAK.

    lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”; mso-bidi-

    lang=EN-AU 9.0pt; font-family:”Arial monospaced for SAP”;mso-bidi-ASSIGN ( c_program_variable) to<fs_symbol>. lang=EN-AU 9.0pt;font-family:”Arial monospaced for SAP”; mso-bidi-

    *******************************

    M.

    (0) 

Leave a Reply