Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ENHANCEMENT( IDOC_INPUT_ORDERS)

Former Member
0 Likes
4,261

WHEN CREATING AN INBOUND IDOC I NEED TO POPULATE VALUES TO SOME OF THE SEGMENTS WHICH IS ALREADY CREATED.

FOR EX.

E1EDKA1 CONTAINS THE PARTNER FN. AG AND WE.

SO I NEED TO MODIFY THE VALUES OF SOLD-TO PARTY AND SHIP-TO PARTY OF FIELD (E1EDKA1-PARTN ).THEREFORE I NEED TO PASS MY VALUES TO THESE SEGMENTS .HOW CAN I DO IT.

THE OPTIONS WHICH I HAVE TRIED IS :

1) CREATED A USER-EXIT IN CMOD.

2) ENHANCEMENT ASSINGMENT : VEDA0001

3) I HAVE WRITTEN MY CODING IN ALL THOSE 12 EXITS BUT IN THE INTERNAL TABLE ALL THE VALUES GET MODIFIED BUT WHEN IDOC IS CREATED NO VALUES R FOUND FOR THIS PARTNER FN.

HELPFULL ANSWERS WILL BE REWARDED WITH POINTS......

PROGRAM:

TABLES: edidd, " Data record(IDoc).

edidc,

e1edka1, " Document Header Partnerinformation.

e1edk14,

zhvt_sapedipart. " SAP EDI Partner

**----


**

    • TABLES DECLARATION

**

**----


DATA: v_zcustgsid1(13),

v_zcustgsid2(13),

v_zcustloc(13),

v_zsoldto(10),

v_zshipto(10),

v_zsalorg(4),

v_zdistchan(2),

v_zdivision(2),

v_tabix TYPE i,

v_flag,

v_segnum TYPE i.

v_zcustgsid1 = didoc_cntrl-rcvlad.

v_zcustgsid2 = didoc_cntrl-sndlad.

READ TABLE didoc_data INTO edidd WITH KEY

segnam = 'E1EDKA1' sdata+0(2) = 'WE'.

e1edka1 = edidd-sdata.

v_zcustloc = e1edka1-ilnnr.

SELECT zsoldto

zshipto

zsalorg

zdistchan

zdivision

FROM zhvt_sapedipart UP TO 1 ROWS

INTO (v_zsoldto,v_zshipto,v_zsalorg,v_zdistchan,

v_zdivision)

WHERE zcustgsid1 = v_zcustgsid1

AND zcustgsid2 = v_zcustgsid2

AND zcustloc = v_zcustloc

AND z856ind = 'X'.

ENDSELECT.

IF sy-subrc EQ 0.

LOOP AT didoc_data INTO edidd WHERE segnam = 'E1EDKA1'

AND ( sdata+0(2) = 'AG'

OR sdata+0(2) = 'WE' ).

v_tabix = sy-tabix.

*assigning the segment 'e1edka1' to the workarea.

e1edka1 = edidd-sdata.

IF e1edka1-parvw = 'AG'.

e1edka1-partn = v_zsoldto.

ELSE.

e1edka1-partn = v_zshipto.

ENDIF.

*moving the values to the structure.

MOVE e1edka1 TO edidd-sdata.

*

**modify the internal table to populate the value.

MODIFY didoc_data FROM edidd INDEX v_tabix

TRANSPORTING sdata.

*clearing the structures.

CLEAR : e1edka1,

edidd.

ENDLOOP.

ELSE.

EXIT.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,219

The problem is that you are updating the wrong table. The exit that needs to be maintained is EXIT_SAPLVEDA_001. Look closer at function IDOC_INPUT_ORDERS in subroutine INTERPRET_IDOC_ORDERS. in this subroutine look for the case condition for segment 'E1EDKA1', this is where partner data is processed. BEFORE exit EXIT_SAPLVEDA_001 is called all segment data is transferred to table XVBADR. This table is then passed to exit EXIT_SAPLVEDA_001 and its contents is available to be changed to whatever you like. On the other hand, what you are doing is attempting to change contents of didoc_data. The problem here is that even if you changed the contents on DIDOC_DATA, the transaction VA01 will not use this data to create the order because the idoc function uses tables XVBAP, XVBEP, XVBADR etc to create the order. In other words, by the time you change the contents of DIDOC_DATA, it is too late. The standard logic in the function have already moved the requried data to these 'X' tables for the order creation. Therefore, it really is a timing issue. To be able to change the contents of DIDOC_DATA in the hope fo changing contents of all the 'X' tables, there must be a user exit that exists before the 'X' tables are populated. Unfortunately there isn't one in this case. The earliest exit that is called is EXIT_SAPLVEDA_001 which by the time it is called, the 'X' tables have already been populated.

To illustrate this, look again at the case condition for segment 'E1EDKA1'. You will see that subroutine zuordnen_orders_e1edka1 populates the 'X' tables and only after that does the subroutine customer_function_idoc is called to call the user exit.

Therefore, just use EXIT_SAPLVEDA_001 but manipulate table XVBADR instead.

Hope this makes sense ....

5 REPLIES 5
Read only

Former Member
0 Likes
3,220

The problem is that you are updating the wrong table. The exit that needs to be maintained is EXIT_SAPLVEDA_001. Look closer at function IDOC_INPUT_ORDERS in subroutine INTERPRET_IDOC_ORDERS. in this subroutine look for the case condition for segment 'E1EDKA1', this is where partner data is processed. BEFORE exit EXIT_SAPLVEDA_001 is called all segment data is transferred to table XVBADR. This table is then passed to exit EXIT_SAPLVEDA_001 and its contents is available to be changed to whatever you like. On the other hand, what you are doing is attempting to change contents of didoc_data. The problem here is that even if you changed the contents on DIDOC_DATA, the transaction VA01 will not use this data to create the order because the idoc function uses tables XVBAP, XVBEP, XVBADR etc to create the order. In other words, by the time you change the contents of DIDOC_DATA, it is too late. The standard logic in the function have already moved the requried data to these 'X' tables for the order creation. Therefore, it really is a timing issue. To be able to change the contents of DIDOC_DATA in the hope fo changing contents of all the 'X' tables, there must be a user exit that exists before the 'X' tables are populated. Unfortunately there isn't one in this case. The earliest exit that is called is EXIT_SAPLVEDA_001 which by the time it is called, the 'X' tables have already been populated.

To illustrate this, look again at the case condition for segment 'E1EDKA1'. You will see that subroutine zuordnen_orders_e1edka1 populates the 'X' tables and only after that does the subroutine customer_function_idoc is called to call the user exit.

Therefore, just use EXIT_SAPLVEDA_001 but manipulate table XVBADR instead.

Hope this makes sense ....

Read only

0 Likes
3,219

Hi Liam,

You are correct. But in IDOC there will be more than one segments ,if you see the code of IDOC_INPUT_ORDERS , the first call to user exit will be just after the first E1EDK01 segment is encountered as this is the first segemnt in the idoc . After each segment exit EXIT_SAPLVEDA_001 will be called as it is in loop.

So in the first call itself ( When segment is E1EDK01 ) if the contents of DIDOC_DATA for segments E1EDKA1 is modified it will have correct effect on XVBADR but EDIDD is not available as a table parameter in the exit . I doubt If the poster has used code "LOOP AT didoc_data" in exit EXIT_SAPLVEDA_001 , I am not sure how as DIDOC_DATA is not a table parameter and simply a work area string . You cannot modify internal table EDIDD in EXIT_SAPLVEDA_001 as this is not available in interface .

So your suggestion to modify XVBADR is correct but this should be modified only when the segment is E1EDKA1 as this exit will be called once for each segment in IDOC . So in this exists a condition like

"IF segment-segnam = 'E1EDKA1'.

Here there is no need to loop as data will be available

in work area SEGMENT .

Code ....

ENDIF."

will suffice.

Cheers

Read only

0 Likes
3,219

THANK U FOR YOUR REPLY LIAM.

But as what sanjay said in exit EXIT_SAPLVEDA_001 , I am sure that DIDOC_DATA is not a table parameter and simply a work area string . You cannot modify internal table EDIDD in EXIT_SAPLVEDA_001 as this is not available in this exit ,DIDOC_DATA is not a table parameter and simply a work area string . so how can i modify and some extra segments to the already existing value.

do u have any sample coding which makes me better to under stand (easier).

surely i will give points i am waiting for both of ur logic to be understood.

Read only

Former Member
0 Likes
3,219

Hi Murali,

Use the EXIT_SAPLVEDA_011 user exit, include ZXVEDU13. We used it a lot to modify/add/delete some information.

Inside this include, you will insert the code something like this. I am not writing the complete code, but just enough to give you an idea.


DATA: S_E1EDKA1 LIKE E1EDKA1.
LOOP AT DEDIDD WHERE SEGNAM = 'E1EDKA1'.
  MOVE DEDIDD-SDATA TO S_E1EDKA1.
*-- do all your logic to modify S_E1EDKA1 here. Not only that you have to 
*   identify the corresponding record of DXVBPA and modify that too.
  MOVE S_E1EDKA1 TO DEDIDD-SDATA.
  MODIFY DEDIDD.
  CLEAR S_E1EDKA1.
ENDLOOP.

Srinivas

Read only

0 Likes
3,219

Hi srinivas,

it was helpfull but do u have the code what u did before to modify and delete segments . so that i can easily try to understand how to modify those xtables.but not all the tables hold values except xvbadr.but i am trying to modify those values but it gets cleared.

waiting for ur reply.

please don't delay.

thanku.