Application Development 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: 

see the values in a STRUCTURE

Former Member
0 Kudos

Hi All,

I need to see all the message types and detils contained in a structure BAPIRET2, can you pls tell me how I do it.

Also need to know how a structure gets populated. pls advice..

Thanks

4 REPLIES 4

Former Member
0 Kudos

Hi,

First thing: STRUCTURE does not hold any values.

You need to reference it like:

data: itab like standard table of BAPIRET2 with header line.

Keep appending the error messages into this table ITAB like:

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

TYPE = sy-msgty'

CL = sy-msgid

NUMBER = sy-msgno

PAR1 = SY-MSGV1

PAR2 = SY-MSGV2

PAR3 = SY-MSGV3

PAR4 = SY-MSGV4

IMPORTING

RETURN = itab.

APPEND itab.

You can then loop through this internal table for all the error messages.

Regards,

Subramanian

Former Member
0 Kudos

Hi

That structure is used to define the parameter (usually called RETURN) where the BAPI returns all messages.

U need to define an internal table like BAPIRET2:

DATA: T_BAPIRET2 TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.

And then u have to read that table after calling the BAPI:

CALL FUNCTION <BAPI>
           EXPORTING
                ...............................................
           TABLES
                ............................................
                RETURN         = T_BAPIRET2 .

       LOOP AT T_BAPIRET2 .
           WRITE: / T_BAPIRET2-MESSAGE.
       ENDLOOP. 

U should considete the field TYPE has the message type, if its value is E or A it means the BAPI has failed.

Max

former_member212653
Active Contributor
0 Kudos

Its a return table of the BAPI. Its populated inside the BAPI depending upon the error types. As BAPIs can't have any exception the error handling is done through return table.

while coding check if there is an message of type "E" or "A" , if yes then there must have been some error.

Former Member
0 Kudos

you can use write statement.just sending overview.



data: ret like bapiret2.
.
.

loop at itab.
CALL FUNCTION 'BAPI_****_******'
  EXPORTING
  * .
  *
. *
 IMPORTING
  *
. 

 write:/ itab-field1, itab-field2, ret.
 endloop.