ā2015 Apr 12 12:53 PM
Hi Frnds
I have declared the below structure and internal table in my program and using the BAPI 'BAPI_PO_GETDETAIL1' am trying to fetch the PO details to the internal table IT_BAPI_TY_1. And the PO values is getting stored in the internal table successfully, but when i loop the table IT_BAPI_TY_1 its getting failed, kindly help me out.
why the values from internal table is not getting moved to the workarea.
TYPES: BEGIN OF IT_BAPI_TY .
INCLUDE STRUCTURE BAPIMEPOHEADER.
TYPES: END OF IT_BAPI_TY,
WA_BAPI TYPE BAPIMEPOHEADER.
DATA: IT_BAPI_TY_1 TYPE STANDARD TABLE OF IT_BAPI_TY WITH HEADER LINE ,
WA_BAPI_1 type IT_BAPI_TY.
CALL FUNCTION 'BAPI_PO_GETDETAIL1'
EXPORTING
PURCHASEORDER = WA_EKKO-EBELN
IMPORTING
POHEADER = IT_BAPI_TY_1.
LOOP AT IT_BAPI_TY_1 INTO WA_BAPI_1.
READ TABLE IT_BAPI_TY_1 INTO WA_BAPI_1 WITH KEY PO_NUMBER = WA_EKKO-EBELN.
ā2015 Apr 12 1:10 PM
If you see FM BAPI_PO_GETDETAIL1 export parameter POHEADER is declared as structure NOT as table type so it will contain only one record.
So declaring internal with header line does not make sense here.You can declare like this
data: wa_poheader type BAPIMEPOHEADER
CALL FUNCTION 'BAPI_PO_GETDETAIL1'
EXPORTING
PURCHASEORDER = WA_EKKO-EBELN
IMPORTING
POHEADER = wa_poheader
if wa_poheader-PO_NUMBER = WA_EKKO-EBELN
<logic>
endif.
ā2015 Apr 12 1:14 PM
Hi Rufus,
Change type of your internal table & WA to BAPIMEPOHEADER.You can use like BAPIMEPOHEADER
Regards,
Kannan
ā2015 Apr 12 1:29 PM
Thanks Soni & Kannan,
one small query, in the BAPI the export parameter POHEADER is defined as
POHEADER like BAPIMEPOHEADER. .
In case if it is defined as POHEADER type BAPIMEPOHEADER - then does my declaration will work ??
ā2015 Apr 12 2:02 PM
Hi Rufus,
That is just parameters you can pass any name there only thing is the type assginment filed should be correct.
You can define any name there.If you have doubt in using this just put a where used list and see how the FM works.Even a simple serach will also bring lot of sample codes which i dont want to paste here.
Just do a small search it will help.
Regards,
Kannan
ā2015 Apr 12 4:42 PM
ā2015 Apr 12 5:55 PM
Hi,
Create a internal table for the Parameters declared in tables tab position available in FM.
Hope it helpful,
Regards,
Venkat