2007 Feb 09 4:48 PM
Hi all ,
Iam getting multiple record in an internal table .i want validate material number and country if both are same i want make it as single record.
now iam getting multiple records in itab1 like this .
matnr,country,event,stdt,eddt
a1 , us , ga, 01/01/2006,01,01/01/2006
a1,us,pa,02/02/2006,02/02/2006
i want make it as in itab2 i want compare material number and country code
and i have to send some other events aslo
a1,us,ga,01/01/2006,01/01/2006,pa,02/02/2006,02/02/2006,ga, , , es, , ,
can any guide me how to do this?
Hi all ,
Iam getting multiple record in an internal table .i want validate material number and country if both are same i want make it as single record.
now iam getting multiple records in itab1 like this .
matnr,country,event,stdt,eddt
a1 , us , ga, 01/01/2006,01,01/01/2006
a1,us,pa,02/02/2006,02/02/2006
i want make it as in itab2 i want compare material number and country code
and i have to send some other events aslo
a1,us,ga,01/01/2006,01/01/2006,pa,02/02/2006,02/02/2006,ga, , , es, , ,
can any guide me how to do this?
2007 Feb 09 4:58 PM
SORT itab1 BY matnr land1 ASCENDING..
DELETE ADJACENT DUPLICATES FROM itab1 COMPARING matnr land1.
2007 Feb 09 5:00 PM
Alex,
i dont want to delte multiple records . I want to make it as single record with material number and country code validation.
2007 Feb 09 5:04 PM
Hi Priya,
sort the itab by material....loop over the itab...then keep appening the values you want into a string and do the append to the 2nd table when the material changed.
Use the control statement AT END of <field> to achieve this...
Thanks.
2007 Feb 09 5:01 PM
Hi,
Do you want the internal table itab2 to be a structured internal table...OR it can be just a string internal table..
THanks,
Naren
2007 Feb 09 5:05 PM
My requirement is i am getting data in itab1 in multiple records (with 10 fields).
iam sending this data to iab2 with some manipulation ( with 20 fields ) here also i have multiple records . Finally i have compare material number and country from itab2 and need to send as single record into file .
2007 Feb 09 5:11 PM
Hi,
Which means..In the internal table itab1 you will always have only 2 records for the same material and country..
Meaning in the internal table itab1 you will not have a third record..Lets say
a1 , us , ga, 01/01/2006,01,01/01/2006
a1,us,pa,02/02/2006,02/02/2006
<b>a1,us,pa,02/03/2006,02/03/2006</b>
Thanks,
Naren
2007 Feb 09 5:15 PM
It depends some times i will have 2 records and some times i will have single record.
2007 Feb 09 5:18 PM
Hi,
I dont understand what problem you are facing:
matnr,country,event,stdt,eddt
a1 , us , ga, 01/01/2006,01,01/01/2006
a1,us,pa,02/02/2006,02/02/2006
First sort the internal table.
Sort itab1 by matnr ascending country ascending.
delete adjacent duplicates from itab1 comparing matnr country.
This should work.
Regards
Subramanian
2007 Feb 09 5:22 PM
yes, what u said is correct some times i will have 2 records and some times i will have single record.
That is the reason we checking count.
if it has multiple records it goes into the loop and concatenates.
if it has single record it remains simply like that.
2007 Feb 09 5:13 PM
Hi Priya,
What u have to do is first u
Sort itab by material number and country.
loop at itab INTO W_ITAB.
count = 0.
itab_dup[] = itab[].
loop at itab_dup INTO W_ITAB_DUP where BANFN eq W_itab-BANFN.
count = count + 1.
append W_itab_dup to itab_result.
endloop.
if count > 1.
loop at itab_result INTO W_ITAB_RESULT where matnr = itab-matnr
and country = itab-country.
concatenate W_ITAB W_ITAB_RESULT into some headerline or Workarea.
endloop.
endif.
CLEAR W_ITAB_RESULT.
refresh itab_result.
endloop.
the above logic collects all duplicate entries in one duplicate table. And the first internal table compares with duplicate internal table, if it exists duplicate records it concatenates.
I think this helps u.
if u get any doubts let me know.
if it helps award points.
Thanks,
Rani
2007 Feb 09 5:23 PM
2007 Feb 09 5:24 PM
2007 Feb 09 5:34 PM
Hi,
Okay try this..
In the internal table ITAB2 have the same set of fields twice in your internal table ending with 1(marked in bold)..
Like..
DATA: BEGIN OF ITAB2 OCCURS 0,
MATNR TYPE MATNR,
COUNTRY TYPE LAND1,
EVENT,
STDT TYPE SYDATUM,
EDDT TYPE SYDATUM,
<b> EVENT1,
STDT1 TYPE SYDATUM,
EDDT1 TYPE SYDATUM,</b>
END OF ITAB2.
DATA: LV_FOUND TYPE XFELD.
DATA: WA LIKE ITAB1.
SORT ITAB1 BY MATNR COUNTRY.
**Make sure in the internal table ITAB1 declaration..The first field is MATNR and
**the second field is country.
LOOP AT ITAB1.
WA = ITAB1.
AT NEW COUNTRY.
Populate the internal table ITAB2.
ITAB2-MATNR = WA-MATNR.
ITAB2-COUNTRY = WA-COUNTRY.
ITAB2-EVENT = ITAB1-EVENT.
ITAB2-STDT = ITAB1-STDT.
ITAB2-ETDT = ITAB1-ETDT.
LV_FOUND = 'X'.
ENDAT.
AT END OF COUNTRY.
IF LV_FOUND IS INITIAL.
**This means the second time.
ITAB2-EVENT1 = ITAB1-EVENT.
ITAB2-STDT1 = ITAB1-STDT.
ITAB2-ETDT1 = ITAB1-ETDT.
ENDIF.
APPEND ITAB2.
CLEAR ITAB2.
ENDAT.
CLEAR: LV_COUNTRY.
ENDLOOP.
Hope this works..
Thanks,
Naren
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |