Hi All,
I have a problem in displaying the output which matl no,matl desc and qty.here for the same matl the qty are 10,20,20,40,50,60,70,80 etc.But i want to display theout put like MATL NO MATL DESC 10 20 30 40 50 and in the next line 60 70 80 90 53
65 43 82 79 25 like this.pls give me solution for this.
Hi Rajendra
Have taken Naren's Code to enable for 50 entries and split in 10 lines of 5 entries each. Please check the below code.
DATA: BEGIN OF ITAB OCCURS 0, MATNR TYPE CHAR4, QTY TYPE INT4, END OF ITAB. DATA: WA LIKE ITAB. ITAB-MATNR = 'ABC'. DO 50 TIMES. ITAB-QTY = SY-INDEX. APPEND ITAB. ENDDO. ITAB-MATNR = 'ABC1'. DO 50 TIMES. ITAB-QTY = SY-INDEX * 2. APPEND ITAB. ENDDO. SORT ITAB BY MATNR. DATA: V_INT TYPE INT4. LOOP AT ITAB. WA = ITAB. AT NEW MATNR. V_INT = 1. WRITE:/ WA-MATNR. ENDAT. IF V_INT >= 1 AND V_INT < 6. WRITE: WA-QTY. ELSE. WRITE: /5 WA-QTY. V_INT = 1. ENDIF. V_INT = V_INT + 1. ENDLOOP.
You can try copying the above code to a temporary program for having a better feel and see that your program incorporates similar kinda logic.
If you still face problem, maybe you can post your code, which can help identifying if there is any problem.
Hope Naren wouldnt mind using his code.
Kind Regards
Eswar
Hi,
Check this sample code..I tested it..
DATA: BEGIN OF ITAB OCCURS 0,
MATNR TYPE CHAR4,
QTY TYPE INT4,
END OF ITAB.
DATA: WA LIKE ITAB.
ITAB-MATNR = 'ABC'.
DO 16 TIMES.
ITAB-QTY = SY-INDEX.
APPEND ITAB.
ENDDO.
ITAB-MATNR = 'ABC1'.
DO 16 TIMES.
ITAB-QTY = SY-INDEX.
APPEND ITAB.
ENDDO.
SORT ITAB BY MATNR.
DATA: V_INT TYPE INT4.
LOOP AT ITAB.
WA = ITAB.
AT NEW MATNR.
WRITE:/ WA-MATNR.
ENDAT.
V_INT = V_INT + 1.
IF V_INT >= 1 AND V_INT < 6.
WRITE: WA-QTY.
ELSE.
WRITE: /5 WA-QTY.
CLEAR: V_INT.
ENDIF.
AT END OF MATNR.
CLEAR: V_INT.
ENDAT.
ENDLOOP.
Thanks,
Naren
Hi,
Check this..
Assuming your internal table declaration is like this..
DATA: BEGIN OF ITAB OCCURS 0,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
QTY TYPE MENGE,
END OF ITAB.
SORT ITAB BY MATNR.
DATA: WA LIKE ITAB.
LOOP AT ITAB.
WA = ITAB.
AT NEW MATNR.
WRITE:/ WA-MATNR, WA-MAKTX.
ENDAT.
V_INT = V_INT + 1.
IF V_INT > 1 AND V_INT < 6.
WRITE: WA-QTY.
ELSE.
WRITE: / WA-QTY.
CLEAR: V_INT.
ENDIF.
AT END OF MATNR.
CLEAR: V_INT.
ENDAT.
ENDLOOP.
Thanks,
Naren
Hi Naren,
My Problem is solved almost still i want to display the second,third,fourth line below the qty only but now it is displaying under the matl no,matl desc( Means the second line starts under the first coulm it suppose to be starts at 3rd colum ie)under qty) and is it possible to do in ALV method if possible pls revert back me.
Thanks,
Raj.
Hi,
For me the first line is ok with qty display in 5 colum,but in the second line the qty is more than 5,but it is not displaying in the third line after 5th colum.suppose the qty is 50 then the qty should display in 10 lines with each line should have only five qtys only.pls help me to solve.
Thanks,
Raj.
Add a comment