on 09-15-2008 5:18 PM
Hi All,
I have the following code six times from matnr2 to matnr7. What is the best way to modify these statements.
If not gs_zcoop-matnr2 IS INITIAL.
WRITE: /01 sy-vline,
04 sy-vline,
07 sy-vline,
10 sy-vline,
13 sy-vline,
22 sy-vline,
53 sy-vline,
75 sy-vline,
89 sy-vline,
90 gs_zcoop-matnr2,
95 sy-vline,
96 gs_zcoop-prdct2,
135 sy-vline,
136 gs_zcoop-camount2,
151 sy-vline,
168 sy-vline,
184 sy-vline,
200 sy-vline,
203 sy-vline,
214 sy-vline,
225 sy-vline,
256 sy-vline,
268 sy-vline,
279 sy-vline,
285 sy-vline,
292 sy-vline,
307 sy-vline,
329 sy-vline,
340 sy-vline,
356 sy-vline.
ENDIF.
If not gs_zcoop-matnr3 IS INITIAL.
WRITE: /01 sy-vline,
04 sy-vline,
07 sy-vline,
10 sy-vline,
13 sy-vline,
22 sy-vline,
53 sy-vline,
75 sy-vline,
89 sy-vline,
90 gs_zcoop-matnr3,
95 sy-vline,
96 gs_zcoop-prdct3,
135 sy-vline,
136 gs_zcoop-camount3,
151 sy-vline,
168 sy-vline,
184 sy-vline,
200 sy-vline,
203 sy-vline,
214 sy-vline,
225 sy-vline,
256 sy-vline,
268 sy-vline,
279 sy-vline,
285 sy-vline,
292 sy-vline,
307 sy-vline,
329 sy-vline,
340 sy-vline,
356 sy-vline.
ENDIF.
Thanks,
Veni.
If not gs_zcoop-matnr2 IS INITIAL.
perform write_line using gs_zcoop-matnr2 .
endif.
If not gs_zcoop-matnr3 IS INITIAL.
perform write_line using gs_zcoop-matnr3 .
endif.
...... etc
form write_line using p_var.
-
the rest of your code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi veni reddy,
try it:
data:
l_tabix type sy-tabix,
l_matnr like gs_zcoop-matnr,
l_prdct like gs_zcoop-prdct,
l_camount like gs_zcoop-camount.
do 6 times.
l_tabix = sy-tabix.
clear: l_matnr, l_prdct, l_camount.
case l_tabix.
when 1.
l_matnr = gs_zcoop-matnr2.
l_prdct = gs_zcoop-prdct2.
l_camount = gs_zcoop-camount2.
when 2.
l_matnr = gs_zcoop-matnr3.
l_prdct = gs_zcoop-prdct3.
l_camount = gs_zcoop-camount3.
when 3.
l_matnr = gs_zcoop-matnr4.
l_prdct = gs_zcoop-prdct4.
l_camount = gs_zcoop-camount4.
when 4.
l_matnr = gs_zcoop-matnr5.
l_prdct = gs_zcoop-prdct5.
l_camount = gs_zcoop-camount5.
when 5.
l_matnr = gs_zcoop-matnr6.
l_prdct = gs_zcoop-prdct6.
l_camount = gs_zcoop-camount6.
when 6.
l_matnr = gs_zcoop-matnr7.
l_prdct = gs_zcoop-prdct7.
l_camount = gs_zcoop-camount7.
when others.
...
endcase.
If not l_matnr IS INITIAL.
WRITE: /01 sy-vline,
04 sy-vline,
07 sy-vline,
10 sy-vline,
13 sy-vline,
22 sy-vline,
53 sy-vline,
75 sy-vline,
89 sy-vline,
90 l_matnr,
95 sy-vline,
96 l_prdct,
135 sy-vline,
136 l_camount,
151 sy-vline,
168 sy-vline,
184 sy-vline,
200 sy-vline,
203 sy-vline,
214 sy-vline,
225 sy-vline,
256 sy-vline,
268 sy-vline,
279 sy-vline,
285 sy-vline,
292 sy-vline,
307 sy-vline,
329 sy-vline,
340 sy-vline,
356 sy-vline.
endif.
enddo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use the Field-Symbols to avoid unnecessary Write Statements.
You can try like:
DATA: BEGIN OF ITAB OCCURS 0,
FIELD1 TYPE CHAR30,
FIELD2 TYPE CHAR30,
FIELD3 TYPE CHAR30,
END OF ITAB.
FIELD-SYMBOLS: <FS> TYPE ANY.
DATA: L_CNT TYPE CHAR10,
L_FIELD TYPE CHAR30.
ITAB-FIELD1 = SY-ABCDE.
ITAB-FIELD3 = SY-ABCDE.
APPEND ITAB.
ITAB-FIELD1 = 1.
ITAB-FIELD2 = 2.
ITAB-FIELD3 = 3.
APPEND ITAB.
LOOP AT ITAB.
DO 3 TIMES.
L_CNT = SY-INDEX.
CONDENSE L_CNT.
CONCATENATE 'ITAB-FIELD' L_CNT INTO L_FIELD.
ASSIGN (L_FIELD) TO <FS>.
WRITE: / <FS>.
ASSIGN SPACE TO <FS>.
ENDDO.
SKIP 1.
ENDLOOP.
Regards,
Naimesh Patel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.