‎2008 Mar 24 8:09 AM
hi,
i have some records in gt_bseg.
i want only those records whose shkzg value = 'H'.
so coded like this.
loop at gt_bseg into wa_bseg .
read table gt_bseg into wa_bseg with key shkzg = 'H' .
if sy-subrc = 0.
move : wa_bseg to wah_bseg.
append wah_bseg to gth_bseg.
endif.
endloop.
loop at gth_bseg into wah_bseg.
write:/2(5) wah_bseg-BUKRS,8(10) wah_bseg-BELNR,20(8) wah_bseg-GJAHR,
30(3) wah_bseg-BSCHL,34(2) wah_bseg-SHKZG,37(2) wah_bseg-MwSKZ,40(9)
wah_bseg-WRBTR.
endloop.
but i am not getting the values . can any one help me?
Thanks
Santosini
‎2008 Mar 24 8:13 AM
instead try this.
DELETE TABLE internal_tab WITH TABLE KEY field ne 'H'.
‎2008 Mar 24 8:12 AM
Hi,
loop at gt_bseg into wa_bseg where shkzg = 'H' .
move-corresponding wa_bseg to wah_bseg.
append wah_bseg to gth_bseg.
endloop.
Reward if helpful.
Regards,
Kumar
‎2008 Mar 24 8:12 AM
Hi,
loop at gt_bseg .
read table gt_bseg into wa_bseg with key shkzg = 'H' .
if sy-subrc = 0.
move : wa_bseg to wah_bseg.
append wah_bseg to gth_bseg.
endif.
endloop.
loop at wah_bseg.
write:/2(5) wah_bseg-BUKRS,8(10) wah_bseg-BELNR,20(8) wah_bseg-GJAHR,
30(3) wah_bseg-BSCHL,34(2) wah_bseg-SHKZG,37(2) wah_bseg-MwSKZ,40(9)
wah_bseg-WRBTR.
endloop.
Now it works...
‎2008 Mar 24 8:13 AM
instead try this.
DELETE TABLE internal_tab WITH TABLE KEY field ne 'H'.
‎2008 Mar 24 8:15 AM
This would delete the pother entries and u can loop at the same internal table and have ur write commands asusal.This is simple way of doing it.
‎2008 Mar 24 8:15 AM
Use sort statement before loop.
sort gt_bseg by shkzg.
loop at gt_bseg into wa_bseg .
read table gt_bseg into wa_bseg with key shkzg = 'H' .
if sy-subrc = 0.
move : wa_bseg to wah_bseg.
append wah_bseg to gth_bseg.
endif.
endloop.
‎2008 Mar 24 8:17 AM
use like that
loop at gt_bseg into wa_bseg .
read table gt_bseg into wa_bseg with key shkzg = 'H' .
if sy-subrc = 0.
move corresonding wa_bseg to wah_bseg.
append wah_bseg to gth_bseg.
endif.
endloop.
Clear:wah_bseg. "need to clear the work area before loop.
loop at gth_bseg into wah_bseg.
write:/2(5) wah_bseg-BUKRS,8(10) wah_bseg-BELNR,20(8) wah_bseg-GJAHR,
30(3) wah_bseg-BSCHL,34(2) wah_bseg-SHKZG,37(2) wah_bseg-MwSKZ,40(9)
wah_bseg-WRBTR.
endloop.
Check the above code i think it will work for u...
Thanks
vipin
‎2008 Mar 24 8:18 AM
Hi,
Put a break point and check what are the values coming in the internal table for SHKZG. There is a possibility that a conversion routine is being used.
Check in the database table is there any conversion routine used. If yes then you have to use some conversion FM.
Reward if helpful.
Regards
Sourabh Verma
‎2008 Mar 24 8:43 AM
Hi,
Check this code.
*loop at gt_bseg into wa_bseg . "comment this line.
read table gt_bseg into wa_bseg with key shkzg = 'H' .
if sy-subrc = 0.
move : wa_bseg to wah_bseg.
append wah_bseg to gth_bseg.
endif.
*endloop."comment this line.
Check it now and let me know,
if you still not gettin values then give the structure of the fields which you have mentioned.
Reward if helpful.
Regards.
‎2008 Mar 24 9:00 AM
hi,
i tried all whatever you suggested but not getting the data.
there are 4 records in the gt_bseg itab.
but its not going inside the loop.
its not reading the data.
thanks
Santosini
‎2008 Mar 24 9:03 AM
Hi,
Have you given the loop inside the
START OF SELECTION.
event ??
Reward if helpful.
Regards.
‎2008 Mar 24 9:07 AM
loop at gt_bseg into wa_bseg .
if wa_bseg-shkzg = 'H' . *<-- write this instead of read *
*read table gt_bseg into wa_bseg with key shkzg = 'H' .
move : wa_bseg to wah_bseg.
append wah_bseg to gth_bseg.
endif.
endloop.
‎2008 Mar 24 9:09 AM
Hi,
You do like this.
loop at gt_bseg into wa_bseg .
if wa_bseg-shkzg = 'H' .
move : wa_bseg to wah_bseg.
append wah_bseg to gth_bseg.
else.
continue.
endif.
endloop.
loop at gth_bseg into wah_bseg.
write:/2(5) wah_bseg-BUKRS,8(10) wah_bseg-BELNR,20(8) wah_bseg-GJAHR,
30(3) wah_bseg-BSCHL,34(2) wah_bseg-SHKZG,37(2) wah_bseg-MwSKZ,40(9)
wah_bseg-WRBTR.
endloop.
Reward.