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

Cannot Loop values from BAPI internal table

former_member462348
Participant
0 Likes
1,024

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.

6 REPLIES 6
Read only

jitendra_it
Active Contributor
0 Likes
917

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.

Read only

Former Member
0 Likes
917

Hi Rufus,

Change type of your internal table & WA to BAPIMEPOHEADER.You can use like BAPIMEPOHEADER

Regards,

Kannan

Read only

former_member462348
Participant
0 Likes
917

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

Read only

0 Likes
917

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

Read only

0 Likes
917

Thanks a lot Kannan

Read only

VenkatRamesh_V
Active Contributor
0 Likes
917

Hi,

Create a internal table for the  Parameters declared in tables tab position available in  FM.

Hope it helpful,

Regards,

Venkat