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

Read row just inserted in table

Former Member
0 Likes
650

Hy experts,

I've got the following problem with this form:

FORM make_out.

SORT tb_app BY rueck rmzhl.

LOOP AT tb_app ASSIGNING <fs_app>.

CALL FUNCTION 'BAPI_ALM_CONF_CANCEL'

EXPORTING

confirmation = <fs_app>-rueck

confirmationcounter = <fs_app>-rmzhl

IMPORTING

return = tb_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ca_x

IMPORTING

return = tb_return.

UNASSIGN <fs_return>.

READ TABLE tb_return ASSIGNING <fs_return>

WITH KEY type = ca_e.

IF sy-subrc = 0.

wa_result-rueck = <fs_app>-rueck.

wa_result-rmzhl = <fs_app>-rmzhl.

wa_result-msg = <fs_return>-message.

wa_result-ex = icon_red_light . "'1'.

APPEND wa_result TO tb_result.

CLEAR wa_result.

ENDIF.

ENDLOOP.

ENDFORM. "make_out

I've to read the current row inserted in table tb_return and check the value of field 'message': if this value is 'E' i insert a row in table wa_result with the values described in the code shown. i wanted to know how to set the read table statement correctly, 'cause in the form you see i don't think it works.

Thanks to all

Ivan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
614

Hi Ivano,

sy-index is the system field for current row position.

Read table <itab> into wa index sy-index.

cheers,

Hema.

4 REPLIES 4
Read only

mnicolai_77
Active Participant
0 Likes
614

hi,

i think that it's happend because u use the same table tb_return in 'BAPI_ALM_CONF_CANCEL' and in 'BAPI_TRANSACTION_COMMIT'. try to use different return or try this way.

>FORM make_out.

>SORT tb_app BY rueck rmzhl.

>

>LOOP AT tb_app ASSIGNING <fs_app>.

>

>CALL FUNCTION 'BAPI_ALM_CONF_CANCEL'

>EXPORTING

>confirmation = <fs_app>-rueck

>confirmationcounter = <fs_app>-rmzhl

>IMPORTING

>return = tb_return.

>UNASSIGN <fs_return>.

>READ TABLE tb_return ASSIGNING <fs_return>

>WITH KEY type = ca_e.

>IF sy-subrc NE 0.

>CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

>EXPORTING

>wait = ca_x

>IMPORTING

>return = tb_return.

>else.

>CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

> endif.

>UNASSIGN <fs_return>.

>

>READ TABLE tb_return ASSIGNING <fs_return>

>WITH KEY type = ca_e.

>IF sy-subrc = 0.

>wa_result-rueck = <fs_app>-rueck.

>wa_result-rmzhl = <fs_app>-rmzhl.

>wa_result-msg = <fs_return>-message.

>wa_result-ex = icon_red_light . "'1'.

>

>APPEND wa_result TO tb_result.

>CLEAR wa_result.

>ENDIF.

>ENDLOOP.

>ENDFORM. "make_out

Call the function 'BAPI_TRANSACTION_COMMIT' make sense if the BAPI which was called before it went well otherwise you should call the 'BAPI_TRANSACTION_ROLLBACK'

Regards

Marco

Edited by: nicolai marco on Jan 20, 2008 12:55 AM

Read only

Former Member
0 Likes
614

No, my problem is that through the first bapi i insert one row in the table tb_return, and then i've got to examine the field 'type' of that row because i've to verify if its value is 'E': if the value of the filed eq 'E' then i make the insertio in wa_result. the problem is with the read statement,

read table tb_return assigning <fs_return> with key type = ca_e

this statement in my opinion doesn't read the row i've just inserted in tb_return, but simply read the first row in the table with type='e', and this isn't what my program must do, it has to examine the row inserted in tb_return, and if the field 'type' ofthat row = 'E' it must insert one row in tb_result. how do i can read the last row inserted into tb_return? could someone tell me how to modify the read statement?

Thanks to all

Ivan

Read only

Former Member
0 Likes
615

Hi Ivano,

sy-index is the system field for current row position.

Read table <itab> into wa index sy-index.

cheers,

Hema.

Read only

0 Likes
614

thaks it's ok.

Ivan