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

convert BAPI tables parameter data from structure to transparent table

Former Member
0 Likes
1,315

Hello experts,

  I am using BAPI_ALM_NOTIF_LIST_EQUI to return a table of Notifications for a piece of equipment using a Tables parameter.

  I want to process just one notification from the internal table 'T_BAPI2080_1', but I cannot use SQL commands because the internal table is formed based on a BAPI table, which has a structure type, not a transparent table type.

  How can I get the data that is in my internal table 'T_BAPI2080_1' from the BAPI structure format to a transparent table format so that I can use SQL to SELECT SINGLE and process one notification from the list?

I am familiar with using SELECT FROM INTO WHERE, but one cannot exercise these commands on an internal table that is of a structure type.

Here is my code:

 

  FUNCTION Z_CODES.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IV_EQUIP) TYPE  EQUI-EQUNR OPTIONAL
*"     VALUE(IV_NOTIF_DATE) TYPE  BAPI2080_1-NOTIFDATE OPTIONAL
*"  EXPORTING
*"     VALUE(EV_NOTIF) TYPE  VIQMEL-QMNUM
*"  TABLES
*"      T_BAPI2080_1 STRUCTURE  BAPI2080_1 OPTIONAL
*"----------------------------------------------------------------------


CALL FUNCTION 'BAPI_ALM_NOTIF_LIST_EQUI'
   EXPORTING
     EQUIPMENT               = IV_EQUIP
    NOTIFICATION_DATE       = IV_NOTIF_DATE
    COMPLETE                = ' '
*   PARTNERFUNCTION         =
*   PARTNER                 =
*   PARTNER_USER            =
* IMPORTING
*   RETURN                  =
   TABLES
     NOTIFICATION            = T_BAPI2080_1

...

This code returns a table that contains the list of all notifications for the equipment.  I want to just select one notification from the return table 'T_BAPI2080_1' to use for further processing.

Thank you.


1 ACCEPTED SOLUTION
Read only

tolga_polat
Active Participant
0 Likes
814

Hi Eric,

I think you missunderstand ABAP table logic.

Internal table is not database table, It's local array for program, so you can not use SELECT for this situation. If you want to access to data in your table you can use READ or LOOP:

data : ls_T_BAPI2080_1 like line of T_BAPI2080_1

" declare work area for your table, if your table has header line you dont need this and in code you dont have to write into statement, but you can not use table with header line in Object oriented ABAP.

READ T_BAPI2080_1

   INTO ls_T_BAPI2080_1

WITH KEY <field> = <value>

Or :

LOOP AT T_BAPI2080_1

      INTO ls_T_BAPI2080_1.

"in here you can use where condition like SELECT statement

ENDLOOP.

I hope this will help.

Tolga

4 REPLIES 4
Read only

Former Member
0 Likes
814

This message was moderated.

Read only

tolga_polat
Active Participant
0 Likes
815

Hi Eric,

I think you missunderstand ABAP table logic.

Internal table is not database table, It's local array for program, so you can not use SELECT for this situation. If you want to access to data in your table you can use READ or LOOP:

data : ls_T_BAPI2080_1 like line of T_BAPI2080_1

" declare work area for your table, if your table has header line you dont need this and in code you dont have to write into statement, but you can not use table with header line in Object oriented ABAP.

READ T_BAPI2080_1

   INTO ls_T_BAPI2080_1

WITH KEY <field> = <value>

Or :

LOOP AT T_BAPI2080_1

      INTO ls_T_BAPI2080_1.

"in here you can use where condition like SELECT statement

ENDLOOP.

I hope this will help.

Tolga

Read only

arindam_m
Active Contributor
0 Likes
814

This message was moderated.

Read only

uppu_narayan
Active Participant
0 Likes
814

Hi Eric,

       the bapi is returning you a internal table, so you can process it with READ or LOOP AT statement and select statements are used when you are interacting with your database table....

thanks and regards,

narayan