‎2010 May 17 6:41 AM
Hi all,
Pls help how to print data as proposed.
Presently the data is printing like this.
Header:
Property Batch1 Batch2
1 m1
2 m2
3 m3
1 m4
2 m5
3 m6My requirememt is to print batch 2 data also on same lines of property.
sample:
Property Batch1 Batch2
1 m1 m4
2 m2 m5
3 m3 m6I know i have to use control brk statements,,pls help me how to use it as required.
Rgs,
Priya
‎2010 May 17 6:49 AM
You can achieve the same even without control-break ., just move the relevnat info (batch2) to the internal table which has batch1 and print it .
‎2010 May 17 6:51 AM
Hi,
Loop the header table and the read the line item table with Property of the header table.
With Regards,
Sumodh.P
Edited by: Sumodh P on May 17, 2010 11:21 AM
‎2010 May 17 6:57 AM
Hi,
Try this below code.
types: begin of typ,
prop(2),
bat(2),
end of typ.
data: itab1 type table of typ WITH HEADER LINE,
itab2 type table of typ WITH HEADER LINE.
First table values*
itab1-prop = 1. itab1-bat = 'm1'.
append itab1.
itab1-prop = 2. itab1-bat = 'm2'.
append itab1.
itab1-prop = 3. itab1-bat = 'm3'.
append itab1.
*Second table values
itab2-prop = 1. itab2-bat = 'm4'.
append itab2.
itab2-prop = 2. itab2-bat = 'm5'.
append itab2.
itab2-prop = 3. itab2-bat = 'm6'.
append itab2.
*Displaying the values , as your required format
LOOP at itab1.
READ TABLE itab2 with key prop = itab1-prop.
write: / itab1-prop,itab1-bat,itab2-bat.
ENDLOOP.
Regards,
Smart
‎2010 May 17 7:08 AM
Hi All,
Thanks for your suggestions.
See I have an internal table ITEMS,, which is filled like this .
1 m1
2 m2
3 m3
---------------
1 m4
2 m5
3 m6My question is how to modify the internal table with respect to property.
In above Internal table there are 6 records. but with same property items repeated.
Now I want to print the batch data on same line if the property data is same.
like this:
1 m1 m4
2 m2 m5
3 m3 m6pls suggest me with useful code.
Rgs,
Priya
‎2010 May 17 7:20 AM
Hi,
Please have a look at the below example.
TYPES : BEGIN OF T_HEADER,
PROPERTY(1) TYPE C,
BATCH(3) TYPE C,
END OF T_HEADER,
BEGIN OF T_LINE,
PROPERTY(1) TYPE C,
BATCH(3) TYPE C,
END OF T_LINE,
BEGIN OF T_FINAL,
PROPERTY(1) TYPE C,
BATCH1(3) TYPE C,
BATCH2(3) TYPE C,
END OF T_FINAL..
DATA : LV_HEADER TYPE TABLE OF T_HEADER,
WA_HEADER TYPE T_HEADER,
LV_ITEM TYPE TABLE OF T_LINE,
WA_ITEM TYPE T_LINE,
LV_FINAL TYPE TABLE OF T_FINAL,
WA_FINAL TYPE T_FINAL.
START-OF-SELECTION.
WA_HEADER-PROPERTY = '1'.
WA_HEADER-BATCH = 'm1'.
APPEND WA_HEADER TO LV_HEADER.
WA_HEADER-PROPERTY = '2'.
WA_HEADER-BATCH = 'm2'.
APPEND WA_HEADER TO LV_HEADER.
WA_HEADER-PROPERTY = '3'.
WA_HEADER-BATCH = 'm3'.
APPEND WA_HEADER TO LV_HEADER.
WA_ITEM-PROPERTY = '1'.
WA_ITEM-BATCH = 'm4'.
APPEND WA_ITEM TO LV_ITEM.
WA_ITEM-PROPERTY = '2'.
WA_ITEM-BATCH = 'm5'.
APPEND WA_ITEM TO LV_ITEM.
WA_ITEM-PROPERTY = '3'.
WA_ITEM-BATCH = 'm6'.
APPEND WA_ITEM TO LV_ITEM.
LOOP AT LV_HEADER INTO WA_HEADER.
LOOP AT LV_ITEM INTO WA_ITEM WHERE PROPERTY = WA_HEADER-PROPERTY.
IF SY-SUBRC EQ 0 .
WA_FINAL-PROPERTY = WA_HEADER-PROPERTY.
WA_FINAL-BATCH1 = WA_HEADER-BATCH.
WA_FINAL-BATCH2 = WA_ITEM-BATCH.
APPEND WA_FINAL TO LV_FINAL.
ENDIF.
ENDLOOP.
ENDLOOP.
With Regards,
Sumodh.P
‎2010 May 17 7:09 AM
Hi Priya,
You can achieve your requirement w/o using Control break statements as follows.
However you will be looping Header internal table for write statement.so inside the loop use read statement for item table and write the batch2 field data.
eg:
Loop at header into wa_header.
Read Item into wa-item with key property = wa_header-property.
Write: /10 wa_header-property ,20 wa_header-batch1, 20 wa_item-batch2.
Endloop.
regards,
Kiruba
‎2010 May 17 7:14 AM
Hi Kiruba,
Im not printing any header. My internal table would populate like as mentioned below.
1 m1
2 m2
3 m3
---------------
1 m4
2 m5
3 m6Im passing this Internal table to Write_Form. So I have to modify this internal table before passing to script.
I hope you got my requirement.
Rgs,
Priya
‎2010 May 17 7:23 AM
Hi,
If you want to print out put like that,
Try this sample code,
sort <internal Table> By <property>.
write: 'Property'.
write:20 'Batch1'.
write:40 'Batch2'.
loop at <internal Table> into <wa>.
at new <Property>.
write: <wa-property> under 'Property'.
write: <wa-Batch1> under 'Batch1'.
endat.
if <wa-batch2> is not initial.
write: <wa-Batch2> under 'Batch2'.
endif.
at end of <Property>.
new-line.
endat.
endloop.
Hope this helps you.
Regards,
Raghava Channooru
‎2010 May 17 7:26 AM
Try something this way
itab1[] = itab[].
loop at itab.
v_tabix = sy-tabix.
read table itab1 with key property = itab-property.
if sy-subrc eq 0.
move itab1-batch2 to itab-batch2.
modify itab index v_tabix transporting batch2.
endif.
endloop.
after this your itab will have values
a®
‎2010 May 17 7:27 AM
Hello Priya,
Sort internal table by prperty thenyour data will be
1 M1
1 M1
2 M2
2 M2
3 M3
3 M3
then inside the loop you move the data in the property to one varibale ( NOTE in first loop pass that varibale should be empty)
in the loop you check whether previous entry and current entry are same or not if same then modify all the field into another new internal table else append the entry in the same internal table where you were modifying the entry .
This is definatly solve your problem
Regards
Sagar
‎2010 May 17 7:30 AM
Hi Sumodh & Raghava,
Have u seen my requirement properly.
@Sumodh: I have an internal table already filled with data. I dont understand why u r asking me to take 3 extra internal tables.
@Raghava: I think I need to do something like as you mentioned,but Im cant use write statement,,Im passing the internal table to script--write_form.
So befor passing to write_form I need to modify the internal table based on property.
Pls help.
Rgs,
priya
‎2010 May 17 7:35 AM
Hello,
Check this sample,
data: begin of itab OCCURS 0,
f1 type string,
f2 type string,
f3 type string,
end of itab.
data: wa_itab like itab.
data: v_index type sy-tabix.
itab-f1 = '1'.
itab-f2 = 'M1'.
append itab.
clear itab.
itab-f1 = '2'.
itab-f2 = 'M2'.
append itab .
clear itab.
itab-f1 = '3'.
itab-f2 = 'M3'.
append itab .
clear itab.
itab-f1 = '1'.
itab-f3 = 'M4'.
append itab.
clear itab.
itab-f1 = '2'.
itab-f3 = 'M5'.
append itab .
clear itab.
itab-f1 = '3'.
itab-f3 = 'M6'.
append itab .
clear itab.
sort itab by f1 f2 f3.
loop at itab.
v_index = sy-tabix + 1.
read table itab into wa_itab INDEX v_index.
if itab-f1 = wa_itab-f1.
itab-f2 = wa_itab-f2 .
modify itab.
endif.
endloop.
DELETE ADJACENT DUPLICATES FROM itab COMPARING f1.
BREAK-POINT.
Vikranth
‎2010 May 17 7:40 AM
Hi ,
Try this.
types: begin of typ,
prop(2),
bat(2),
end of typ.
data: itab1 type table of typ WITH HEADER LINE,
wa type typ.
itab1-prop = 1. itab1-bat = 'm1'.
append itab1.
itab1-prop = 2. itab1-bat = 'm2'.
append itab1.
itab1-prop = 3. itab1-bat = 'm3'.
append itab1.
itab1-prop = 1. itab1-bat = 'm4'.
append itab1.
itab1-prop = 2. itab1-bat = 'm5'.
append itab1.
itab1-prop = 3. itab1-bat = 'm6'.
append itab1.
sort itab1 by prop bat.
LOOP at itab1.
wa = itab1.
AT new prop.
write: / wa-prop,wa-bat.
ENDAT.
AT END OF prop.
write: wa-bat.
ENDAT.
ENDLOOP.
Regards,
Smart.
‎2010 May 17 7:44 AM
Hi!! I have created a test program using CONTROL BREAK STATEMENT.
Please check the sample code below.
Hope this would solve your problem.
TYPES: BEGIN OF ty_tab,
priority TYPE char2,
batch1 TYPE char2,
batch2 TYPE char3,
END OF ty_tab.
DATA it_tab TYPE STANDARD TABLE OF ty_tab.
DATA it_tab1 TYPE STANDARD TABLE OF ty_tab.
DATA:w_tab TYPE ty_tab,
w_tab1 TYPE ty_tab.
w_tab-priority = '1'.
w_tab-batch1 = 'm1'.
APPEND w_tab TO it_tab.
CLEAR w_tab.
w_tab-priority = '2'.
w_tab-batch1 = 'm2'.
APPEND w_tab TO it_tab.
CLEAR w_tab.
w_tab-priority = '3'.
w_tab-batch1 = 'm3'.
APPEND w_tab TO it_tab.
CLEAR w_tab.
w_tab-priority = '1'.
w_tab-batch2 = 'm4'.
APPEND w_tab TO it_tab.
CLEAR w_tab.
w_tab-priority = '2'.
w_tab-batch2 = 'm5'.
APPEND w_tab TO it_tab.
CLEAR w_tab.
w_tab-priority = '3'.
w_tab-batch2 = 'm6'.
APPEND w_tab TO it_tab.
CLEAR w_tab.
SORT it_tab BY priority.
LOOP AT it_tab INTO w_tab.
AT NEW priority.
IF sy-tabix GT 1.
APPEND w_tab1 TO it_tab1.
CLEAR w_tab1.
ENDIF.
w_tab1-priority = w_tab-priority.
ENDAT.
IF NOT w_tab-batch1 IS INITIAL.
w_tab1-batch1 = w_tab-batch1.
ENDIF.
IF NOT w_tab-batch2 IS INITIAL.
w_tab1-batch2 = w_tab-batch2.
ENDIF.
CLEAR w_tab.
ENDLOOP.
APPEND w_tab1 TO it_tab1.
Edited by: pintoo2805 on May 17, 2010 8:45 AM
‎2010 May 17 1:24 PM
dear all,
Thanks for ur inputs.
I got it.
sample code:
REPORT zrltest .
DATA: BEGIN OF items OCCURS 0,
prop(5) TYPE c,
value1 TYPE c,
value2 TYPE c,
value3 TYPE c,
END OF items,
BEGIN OF items1 OCCURS 0,
prop(5) TYPE c,
value1 TYPE c,
value2 TYPE c,
value3 TYPE c,
END OF items1.
items-prop = 'Rasi' .
items-value1 = 1.
APPEND items.
items-prop = 'Shah' .
items-value1 = 2.
APPEND items.
items-prop = 'mast' .
items-value1 = 3.
APPEND items.
items-prop = 'Rasi' .
items-value1 = 1.
items-value2 = 'a'.
APPEND items.
items-prop = 'Shah' .
items-value1 = 2.
items-value2 = 'b'.
APPEND items.
items-prop = 'mast' .
items-value1 = 3.
items-value2 = 'c'.
APPEND items.
items-prop = 'Rasi' .
items-value1 = 1.
items-value2 = 'a'.
items-value3 = 9.
APPEND items.
items-prop = 'Shah' .
items-value1 = 2.
items-value2 = 'b'.
items-value3 = 8.
APPEND items.
items-prop = 'mast' .
items-value1 = 3.
items-value2 = 'c'.
items-value3 = 7.
APPEND items.
DATA: w_tabix TYPE sy-tabix.
WRITE:/1 'BEFORE'.
LOOP AT items.
WRITE:/5 items-prop,
12 items-value1,
15 items-value2,
19 items-value3.
ENDLOOP.
LOOP AT items.
READ TABLE items1 WITH KEY prop = items-prop.
w_tabix = sy-tabix.
IF sy-subrc NE 0.
items1-prop = items-prop.
items1-value1 = items-value1.
APPEND items TO items1.
ELSE.
IF items1-value2 IS INITIAL.
items1-value2 = items-value2.
MODIFY items1 INDEX w_tabix TRANSPORTING value2.
CLEAR w_tabix.
ELSEIF items1-value3 IS INITIAL.
items1-value3 = items-value3.
MODIFY items1 INDEX w_tabix TRANSPORTING value3.
CLEAR w_tabix.
ENDIF.
ENDIF.
ENDLOOP.
‎2010 May 17 2:04 PM
Hi Priya,
According to your input,
You can done in this way also.Instead of reading and modifying Internal table every time.
IF ITEMS1 IS NOT INITIAL.
APPEND LINES OF ITEMS1 TO ITEMS.
ENDIF.
SORT ITEMS BY PROP VALUE1.
LOOP AT ITEMS.
AT NEW prop.
ITEMS1-prop = ITEMS-prop.
ENDAT.
IF ITEMS-VALUE1 IS NOT INITIAL.
ITEMS1-VALUE1 = ITEMS-VALUE1.
ENDIF.
IF ITEMS-VALUE2 IS NOT INITIAL.
ITEMS1-VALUE2 = ITEMS-VALUE2.
ENDIF.
IF ITEMS-VALUE3 IS NOT INITIAL.
ITEMS1-VALUE3 = ITEMS-VALUE3.
ENDIF.
AT END OF PROP.
MODIFY ITEMS1 TRANSPORTING value2 value3 WHERE PROP = ITEMS1-PROP .
if sy-subrc ne 0.
APPEND items1.
endif.
ENDAT.
ENDLOOP.
Regards,
Raghava Channooru.