Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

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]>

</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'>

</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'>

</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>

20 Comments