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

problem with READ statement

Former Member
0 Likes
436

hi,

my data declarations and code is as follows:

types:ty_bapi_return LIKE bapiret2.

data: t_return TYPE STANDARD TABLE OF ty_bapi_return,

wa_return TYPE ty_bapi_return.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = wa_bapi_hdr

TABLES

accountgl = t_accountgl

currencyamount = t_currencyamount

return = t_return.

READ TABLE t_return INTO wa_return WITH KEY type = 'E'.

MOVE: wa_return-type TO wa_msg_table-type,

wa_return-message TO wa_msg_table-message,

wa_return-message_v2 TO wa_msg_table-message_v2,

wa_bkpf-belnr TO wa_msg_table-belnr,

wa_bkpf-gjahr TO wa_msg_table-gjahr,

wa_bkpf-bukrs TO wa_msg_table-bukrs.

APPEND wa_msg_table TO t_msg_table.

CLEAR wa_msg_table.

CONTINUE.

ELSEIF wa_return-type = 'S'.

  • call bapi_transaction_commit

CLEAR wa_commit_return1.

REFRESH t_commit_return1.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

IMPORTING

return = t_commit_return1.

Now when i debug and see wa_return , i cant find any values in wa_return.but the table t_return has 2 rows with type 'S'.can anyone tell me what the problem is..thank you.

regards,

Challa.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
404

READ TABLE t_return INTO wa_return WITH KEY type = 'E'.

If you reading the table looking for TYPE "E"...And the table only got 2 rows with TYPE "S"...You will get a line into WA_RETURN...

If you want records in WA_RETURN, you should write this...


READ TABLE t_return INTO wa_return WITH KEY type = 'S'.

"E" stands for error...If your BAPI have been well performed...You're not going to get any errors -;)

Greetings,

Blag.

3 REPLIES 3
Read only

Former Member
0 Likes
405

READ TABLE t_return INTO wa_return WITH KEY type = 'E'.

If you reading the table looking for TYPE "E"...And the table only got 2 rows with TYPE "S"...You will get a line into WA_RETURN...

If you want records in WA_RETURN, you should write this...


READ TABLE t_return INTO wa_return WITH KEY type = 'S'.

"E" stands for error...If your BAPI have been well performed...You're not going to get any errors -;)

Greetings,

Blag.

Read only

amit_khare
Active Contributor
0 Likes
404

thats perfectly right because yor are checking KEY TYPE = 'E' and t_return has value 'S', o the condition fails and return no records in wa_return.

Regards,

Amit

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Read only

Former Member
0 Likes
404

READ doesn't work that way. When you:

READ TABLE t_return INTO wa_return WITH KEY type = 'E'.

It will only return the first occurrence that exactly matches the key(s) you specify. If none match, you will get nothing even though other records are in the table.

You probably want to use a LOOP to read all records.

Rob