Tuesday, March 8, 2016

Idoc user exits - fetch item number from parent segment

 
Demo code for Idoc (EDI) user exits, where you don’t get item number in all segments.  This shows how to fetch item number from Parent segment (E1EDP01 in this case).
 
E1EDPA1 (Partner function segment in ORDERS idoc) does NOT have item number in it, So fetch from parent E1EDP01 (Item details) segment. To do that, write LOOP with  segnam = E1EDP01 or E1EDPA1 – demo code is shown below.
 
    LOOP AT int_edidd ASSIGNING <fs_edidd> WHERE segnam 'E1EDP01'
                                             
OR  segnam 'E1EDPA1'.

      
IF <fs_edidd>-segnam 'E1EDP01'.
        
CLEAR ls_e1edp01,
                lv_ebelp
.
        ls_e1edp01 
<fs_edidd>-sdata.
        lv_ebelp   
=  ls_e1edp01-posex.
        
CONTINUE.
      
ENDIF.

      
CLEARls_e1edpa1.
      
CHECK  <fs_edidd>-sdata+0(2) = 'WE'.
      ls_e1edpa1 
<fs_edidd>-sdata.

      
REFRESHlt_po_del_addr[].
*     Get  PO del address
      
CALL FUNCTION 'BAPI_PO_GETDETAIL1'
        
EXPORTING
          PURCHASEORDER    
xekko-ebeln
          DELIVERY_ADDRESS 
'X'
        
TABLES
          POADDRDELIVERY   
lt_po_del_addr.

*     Get Item PO delivery address
      
CLEARls_po_del_addr.
      
READ TABLE lt_po_del_addr INTO ls_po_del_addr WITH KEY po_item lv_ebelp.
      
IF sy-subrc EQ 0.
        ls_e1edpa1
-strs2 ls_po_del_addr-str_suppl3.
        ls_e1edpa1
-pfach ls_po_del_addr-location.
        <fs_edidd>
-sdata ls_e1edpa1.
      
ENDIF.
    
ENDLOOP.
 

No comments:

Post a Comment