I am displaying created on field (erdat) for MM report.
According to the code :
* For line item 10 , the creation of line item is
* updated as change in EKKO table in CDPOS.
* the creation of rest of the items are updated as EKPO .
* the line items are recognised by the ebelp and comparing
* it with TABKEY from CDPOS.
IF i_pedidos-ebelp = '00010'.
READ TABLE i_cdpos WITH KEY tabname = 'EKKO'.
IF sy-subrc = 0.
READ TABLE i_cdhdr WITH KEY changenr = i_cdpos-changenr.
IF sy-subrc = 0 .
i_pedidos-erdat = i_cdhdr-udate.
ENDIF.
ENDIF.
ELSE.
READ TABLE i_cdpos WITH KEY tabname = 'EKPO'
tabkey = l_tabkey.
IF sy-subrc = 0.
READ TABLE i_cdhdr WITH KEY changenr = i_cdpos-changenr.
IF sy-subrc = 0 .
i_pedidos-erdat = i_cdhdr-udate.
ENDIF.
ENDIF.
ENDIF.
MODIFY i_pedidos TRANSPORTING erdat.
For line item 10 , the code works fine but for other line items the else condition:
ELSE.
READ TABLE i_cdpos WITH KEY tabname = 'EKPO'
tabkey = l_tabkey.
IF sy-subrc = 0.
has sy-subrc = 4. and so I am unable to display the erdat field for line items other than 10.
Can anybody explain what is going wrong here?