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: 

Regarding Passing values into int

Former Member
0 Kudos

Hi all

My Requirement like this

Main table:

Vbeln posnr uepos fkimg

0090000129 10 0 0.000

0090000129 11 0 25.000

0090000129 20 10 10.000

0090000129 30 20 50.000

0090000129 40 10 22.000

If uepos = 0 then pass to one internal table

Output :

0090000129 10 0 0.000

0090000129 11 0 25.000

Next case :

If POSNR = 0 then check all item UEPOS of any equal to POSNR and sub POSNR I mean to say in that 20 POSNR is depending on 10 UEPOS

30 POSNR is depending on 20 UEPOS

30 POSNR is indirectly depending 10 so it also print in output internal table.

Output like this :

0090000129 10 0 0.000

0090000129 20 10 10.000

0090000129 30 20 50.000

0090000129 40 10 22.000

any logic .

Thanks & Regards

sri

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try this logic(for the second internal table).



itab1[] = itab[].

LOOP AT itab.

  IF itab-uepos = 0.
    WRITE:/ itab-posnr , itab-uepos.

    LOOP AT itab1 FROM sy-tabix.

      READ TABLE itab1 WITH KEY uepos = itab-posnr.

      IF sy-subrc EQ 0.
        WRITE:/ itab1-posnr , itab1-uepos.
        itab-posnr = itab1-posnr.
        DELETE itab1 INDEX sy-tabix.
      ENDIF.
    ENDLOOP.
    EXIT.
  ENDIF.
ENDLOOP.

instead of write you can move it to your internal table.

5 REPLIES 5

Former Member
0 Kudos

requirement not clear

0 Kudos

>

> requirement not clear

Hi,

thank u for quick reply,

This is Main Internal table :

Main internal table:

Vbeln -


posnr -


uepos --- fkimg

0090000129 --- 10 -


0 -


0.000

0090000129 --- 11 --- 0 -


25.000

0090000129 --- 20 -


10 --- 10.000

0090000129 -


30 --- 20 -


50.000

0090000129 ---40 -


10 -


22.000

Pass values into two internal table depending on conditions .

1 ) If uepos = 0 then pass to one internal table

Passing 1 internal table :

Output :

0090000129 --- 10 -


0 -


0.000

0090000129 -


11 -


0 -


25.000

This is i can do.

2) if UEPOS is 0 then taken POSNR VALUE ( ex: 10 ) check this in all UEPOS

VBELN --- POSNER --- UEPOS --- FKIMG

0090000129 --- 10 -


0 --- 0.000 ;

( POSNR = UEPOS ) if sucess then pass into 2nd internal table .

here 20 Posner is equal to 10 UEPOS

VBELN --- POSNER -- UEPOS --- FKIMG

0090000129 --- 20 --- 10 --- 10.000

next check

if posner (20) is equal to any remaing main intertable UEPOS is equal to 20 or not.

if sucess pass to 2nd internal table

here ex.

0090000129 -- 30 --- 20 --- 50.000

same final my 2nd internal table output like this

VBELN -


POSNER --- UEPOS --- FKIMG

0090000129 -


10 --- 0 --- 0.000

0090000129 --- 20 --- 10 --- 10.000

0090000129 --- 30 --- 20 --- 50.000

0090000129 --- 40 --- 10 --- 22.000

Thanks and regards

sri.

0 Kudos

Hi Srinivas,

You can try the below logic.

1. Pass all the values of your main internal table in to a temporary internal table.

it_maintab_temp[] = it_maintab[].

2. now,

Loop at it_maintab into wa_maintab.

IF UEPOS ne 0.
" Pass it to the internal table - 1
ELSE.
" Here if it is always one record, you can use Read. 
" If you may get multiple records, you can loop into 
" temporary internal table.
  READ it_maintab_temp with table key UEPOS = wa_maintab-POSNR.
  IF sy-subrc eq 0.
" Pass the values to your second internal table.
  ENDIF.
ENDIF.

Endloop.

Best Regards,

Ram.

Edited by: ram Kumar on Jan 20, 2009 12:46 PM

0 Kudos

ok...u can do like dis....

i understand dat for uepos eq 0 ,u have to check the posnr only for same vbeln ...rt???

den here it is..

loop at itab into wa.

if wa-uepos = 0.

"pass to first itab1.

*second internal table

append wa to itab2. "first record with uepos = 0.

read table itab into wa1 with key vbeln = wa-vbeln uepos = wa-posnr.

if sy-subrc = 0.

append wa1 to itab2.

endif.

else.

read table itab into wa1 with key vbeln = wa-vbeln uepos = 0.

if sy-subrc = 0.

read table itab into wa2 with key vbeln = wa-vbeln uepos = wa-posnr.

if sy-subrc = 0.

append wa2 to itab2.

endif.

endif.

endif.

endloop.

Former Member
0 Kudos

Hi,

Try this logic(for the second internal table).



itab1[] = itab[].

LOOP AT itab.

  IF itab-uepos = 0.
    WRITE:/ itab-posnr , itab-uepos.

    LOOP AT itab1 FROM sy-tabix.

      READ TABLE itab1 WITH KEY uepos = itab-posnr.

      IF sy-subrc EQ 0.
        WRITE:/ itab1-posnr , itab1-uepos.
        itab-posnr = itab1-posnr.
        DELETE itab1 INDEX sy-tabix.
      ENDIF.
    ENDLOOP.
    EXIT.
  ENDIF.
ENDLOOP.

instead of write you can move it to your internal table.