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

Modifying a Table: Two corresponding values for a single entry

Former Member
0 Likes
349

The following select statement of mine sometime picks up two invoice nos (more than one) for a single gate entry number.

SELECT INVOICE_NO GATE_ENTRY_NUM

INTO CORRESPONDING FIELDS OF TABLE I_ZFBPS_INV_LINK

FROM ZFBPS_INV_LINK

FOR ALL ENTRIES IN GATEIN_ITAB

WHERE GATE_ENTRY_NUM = GATEIN_ITAB-GATE_ENTRY_NUM.

Now when I try to modify my GATEIN_ITAB (main internal table) for the INVOICE_NO in the following manner the system encounters the two Invoice Nos against the Gate_Entry_Number in where clause and doesn't modify the table.

LOOP AT I_ZFBPS_INV_LINK.

LOOP AT GATEIN_ITAB WHERE GATE_ENTRY_NUM =

I_ZFBPS_INV_LINK-GATE_ENTRY_NUM.

GATEIN_ITAB-INVOICE_NO = I_ZFBPS_INV_LINK-INVOICE_NO.

MODIFY GATEIN_ITAB INDEX SY-TABIX.

ENDLOOP.

ENDLOOP.

I want both the invoice nos in my output against this gate entry number.

How to do this please advice.

Regards,

Alok.

2 REPLIES 2
Read only

former_member186741
Active Contributor
0 Likes
329

you will need to modify the existing entry in your original table but insert duplicate entries for the subsequent enties.

Something like:

data l_index type sy-tabix.

LOOP AT I_ZFBPS_INV_LINK.

clear l_index.

LOOP AT GATEIN_ITAB WHERE GATE_ENTRY_NUM =

I_ZFBPS_INV_LINK-GATE_ENTRY_NUM.

add 1 to l_index.

GATEIN_ITAB-INVOICE_NO = I_ZFBPS_INV_LINK-INVOICE_NO.

  • first time for this gate entry....

if l_index = 1.

*...change original

MODIFY GATEIN_ITAB INDEX SY-TABIX.

else.

  • subsequent...insert duplicate

append gatein_itab.

endif.

ENDLOOP.

ENDLOOP.

Read only

Former Member
0 Likes
329

hi ...

please use the condition when you want to modify it

SELECT INVOICE_NO GATE_ENTRY_NUM
INTO CORRESPONDING FIELDS OF TABLE I_ZFBPS_INV_LINK
FROM ZFBPS_INV_LINK
FOR ALL ENTRIES IN GATEIN_ITAB
WHERE GATE_ENTRY_NUM = GATEIN_ITAB-GATE_ENTRY_NUM.


LOOP AT I_ZFBPS_INV_LINK.
read table  GATEIN_ITAB  with key  GATE_ENTRY_NUM =  I_ZFBPS_INV_LINK-GATE_ENTRY_NUM
****just    have  if  logic    it will work   
IF  GATEIN_ITAB-INVOICE_NO = I_ZFBPS_INV_LINK-INVOICE_NO   .
MODIFY GATEIN_ITAB INDEX SY-TABIX.
ENDIF .
ENDLOOP.

Reward points ...

girish