2007 Jul 28 12:45 PM
Hi Experts,
As i have very less experience in SAP , can anyone please help me.
The report code i attached here generate only 10 columns in the report and all the lines in internal table i am showing in these 10 columns, the problem is if i have more that 10 lines in the tline(script for long material text- MM03) then it leaves those lines, so
I need to create a dynamic report for this which will create columns depending on the lines in the tline.As i dnt no much about ALV i read so namy things but not able to make it dynamic
Please, can anyone help me by doing changes in this code and make it dynamic report/ALV
REPORT zmm_test_mat_desc.
TABLES : ekpo,makt, t001w.
TYPE-POOLS: slis.
DATA : thread LIKE thead.
DATA : l_index LIKE sy-tabix.
DATA : p_index LIKE sy-tabix.
DATA: BEGIN OF int_out OCCURS 0,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
tdline1 LIKE tline-tdline,
tdline2 LIKE tline-tdline,
tdline3 LIKE tline-tdline,
tdline4 LIKE tline-tdline,
tdline5 LIKE tline-tdline,
tdline6 LIKE tline-tdline,
tdline7 LIKE tline-tdline,
tdline8 LIKE tline-tdline,
tdline9 LIKE tline-tdline,
tdline10 LIKE tline-tdline,
werks LIKE ekpo-werks,
END OF int_out.
DATA: BEGIN OF int_out_new OCCURS 0,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
tdline1 LIKE tline-tdline,
tdline2 LIKE tline-tdline,
tdline3 LIKE tline-tdline,
tdline4 LIKE tline-tdline,
tdline5 LIKE tline-tdline,
tdline6 LIKE tline-tdline,
tdline7 LIKE tline-tdline,
tdline8 LIKE tline-tdline,
tdline9 LIKE tline-tdline,
tdline10 LIKE tline-tdline,
tline LIKE tline OCCURS 0,
werks LIKE ekpo-werks,
END OF int_out_new.
DATA: it_tlines LIKE tline OCCURS 10 WITH HEADER LINE.
**************************
****ALV list definintion
*************************
DATA: ws_cat TYPE slis_fieldcat_alv ,
int_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA : it_heading TYPE slis_t_listheader WITH HEADER LINE.
*DATA : it_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA : lay TYPE slis_layout_alv.
DATA : it_sort_subtotal TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA : it_event TYPE slis_t_event WITH HEADER LINE.
.
DATA: v_repid LIKE sy-repid.
*****************
*selection-screen
*****************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_werks FOR ekpo-werks OBLIGATORY .
SELECT-OPTIONS: s_matnr FOR makt-matnr OBLIGATORY .
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
AT SELECTION-SCREEN.
SELECT SINGLE * FROM t001w WHERE werks IN s_werks.
IF sy-subrc NE 0.
MESSAGE e001(319) WITH 'Plant does not Exist!'.
ENDIF.
SELECT SINGLE * FROM makt WHERE matnr IN s_matnr.
IF sy-subrc <> 0.
MESSAGE e001(319) WITH 'Material does not Exist!'.
ENDIF.
START-OF-SELECTION.
BREAK-POINT.
PERFORM get_data.
PERFORM field_catalog.
PERFORM display_data.
END-OF-SELECTION.
*FORM GET_DATA.
FORM get_data.
DATA: l_index LIKE sy-tabix.
*To Fetch Data From Makt.
SELECT b~werks a~matnr a~maktx
INTO CORRESPONDING FIELDS OF TABLE int_out
FROM makt AS a INNER JOIN marc AS b ON a~matnr = b~matnr
WHERE a~matnr IN s_matnr
AND b~werks IN s_werks.
LOOP AT int_out.
l_index = sy-tabix.
read table int_out_new with key matnr = int_out-matnr.
int_out_new-werks = int_out-werks.
int_out_new-matnr = int_out-matnr.
int_out_new-maktx = int_out-maktx.
*
thread-tdname = int_out-matnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'BEST'
language = sy-langu
name = thread-tdname
object = 'MATERIAL'
TABLES
lines = it_tlines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
*Loop on it_tlines where long text is coming .
LOOP AT it_tlines.
IF sy-subrc = 0.
p_index = sy-tabix.
IF p_index = 1.
int_out_new-tdline1 = it_tlines-tdline.
ELSEIF p_index = 2.
int_out_new-tdline2 = it_tlines-tdline.
ELSEIF p_index = 3.
int_out_new-tdline3 = it_tlines-tdline.
ELSEIF p_index = 4.
int_out_new-tdline4 = it_tlines-tdline.
ELSEIF p_index = 5.
int_out_new-tdline5 = it_tlines-tdline.
ELSEIF p_index = 6.
int_out_new-tdline6 = it_tlines-tdline.
ELSEIF p_index = 7.
int_out_new-tdline7 = it_tlines-tdline.
ELSEIF p_index = 8.
int_out_new-tdline8 = it_tlines-tdline.
ELSEIF p_index = 9.
int_out_new-tdline9 = it_tlines-tdline.
ELSEIF p_index GE 10.
int_out_new-tdline10 = it_tlines-tdline.
ENDIF.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM int_out .
APPEND int_out_new.
CLEAR int_out_new.
ENDLOOP.
Field Catalog
***MATERIAL NO no
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'WERKS'.
int_fcat-reptext_ddic = 'Plant'.
APPEND int_fcat .
***MATERIAL NO no
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'MATNR'.
int_fcat-reptext_ddic = 'Material N0'.
APPEND int_fcat .
*material Short Description
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'MAKTX'.
int_fcat-reptext_ddic = 'Material Short Description'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '45'.
APPEND int_fcat .
Material Long Description1
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE1'.
int_fcat-reptext_ddic = 'Material Long Description1'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description2
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE2'.
int_fcat-reptext_ddic = 'Material Long Description2'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description3
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE3'.
int_fcat-reptext_ddic = 'Material Long Description3'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description4
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE4'.
int_fcat-reptext_ddic = 'Material Long Description4'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description5
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE5'.
int_fcat-reptext_ddic = 'Material Long Description5'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description5
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE5'.
int_fcat-reptext_ddic = 'Material Long Description5'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description5
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE5'.
int_fcat-reptext_ddic = 'Material Long Description5'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description6
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE6'.
int_fcat-reptext_ddic = 'Material Long Description6'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description7
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE7'.
int_fcat-reptext_ddic = 'Material Long Description7'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description8
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE8'.
int_fcat-reptext_ddic = 'Material Long Description8'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description9
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE9'.
int_fcat-reptext_ddic = 'Material Long Description9'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description10
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE10'.
int_fcat-reptext_ddic = 'Material Long Description10'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = int_fcat[]
TABLES
t_outtab = int_out_new
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "display_data
Regards
Nik.
Hi Experts,
As i have very less experience in SAP , can anyone please help me.
The report code i attached here generate only 10 columns in the report and all the lines in internal table i am showing in these 10 columns, the problem is if i have more that 10 lines in the tline(script for long material text- MM03) then it leaves those lines, so
I need to create a dynamic report for this which will create columns depending on the lines in the tline.As i dnt no much about ALV i read so namy things but not able to make it dynamic
Please, can anyone help me by doing changes in this code and make it dynamic report/ALV
REPORT zmm_test_mat_desc.
TABLES : ekpo,makt, t001w.
TYPE-POOLS: slis.
DATA : thread LIKE thead.
DATA : l_index LIKE sy-tabix.
DATA : p_index LIKE sy-tabix.
DATA: BEGIN OF int_out OCCURS 0,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
tdline1 LIKE tline-tdline,
tdline2 LIKE tline-tdline,
tdline3 LIKE tline-tdline,
tdline4 LIKE tline-tdline,
tdline5 LIKE tline-tdline,
tdline6 LIKE tline-tdline,
tdline7 LIKE tline-tdline,
tdline8 LIKE tline-tdline,
tdline9 LIKE tline-tdline,
tdline10 LIKE tline-tdline,
werks LIKE ekpo-werks,
END OF int_out.
DATA: BEGIN OF int_out_new OCCURS 0,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
tdline1 LIKE tline-tdline,
tdline2 LIKE tline-tdline,
tdline3 LIKE tline-tdline,
tdline4 LIKE tline-tdline,
tdline5 LIKE tline-tdline,
tdline6 LIKE tline-tdline,
tdline7 LIKE tline-tdline,
tdline8 LIKE tline-tdline,
tdline9 LIKE tline-tdline,
tdline10 LIKE tline-tdline,
tline LIKE tline OCCURS 0,
werks LIKE ekpo-werks,
END OF int_out_new.
DATA: it_tlines LIKE tline OCCURS 10 WITH HEADER LINE.
**************************
****ALV list definintion
*************************
DATA: ws_cat TYPE slis_fieldcat_alv ,
int_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA : it_heading TYPE slis_t_listheader WITH HEADER LINE.
*DATA : it_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA : lay TYPE slis_layout_alv.
DATA : it_sort_subtotal TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA : it_event TYPE slis_t_event WITH HEADER LINE.
.
DATA: v_repid LIKE sy-repid.
*****************
*selection-screen
*****************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_werks FOR ekpo-werks OBLIGATORY .
SELECT-OPTIONS: s_matnr FOR makt-matnr OBLIGATORY .
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
AT SELECTION-SCREEN.
SELECT SINGLE * FROM t001w WHERE werks IN s_werks.
IF sy-subrc NE 0.
MESSAGE e001(319) WITH 'Plant does not Exist!'.
ENDIF.
SELECT SINGLE * FROM makt WHERE matnr IN s_matnr.
IF sy-subrc <> 0.
MESSAGE e001(319) WITH 'Material does not Exist!'.
ENDIF.
START-OF-SELECTION.
BREAK-POINT.
PERFORM get_data.
PERFORM field_catalog.
PERFORM display_data.
END-OF-SELECTION.
*FORM GET_DATA.
FORM get_data.
DATA: l_index LIKE sy-tabix.
*To Fetch Data From Makt.
SELECT b~werks a~matnr a~maktx
INTO CORRESPONDING FIELDS OF TABLE int_out
FROM makt AS a INNER JOIN marc AS b ON a~matnr = b~matnr
WHERE a~matnr IN s_matnr
AND b~werks IN s_werks.
LOOP AT int_out.
l_index = sy-tabix.
read table int_out_new with key matnr = int_out-matnr.
int_out_new-werks = int_out-werks.
int_out_new-matnr = int_out-matnr.
int_out_new-maktx = int_out-maktx.
*
thread-tdname = int_out-matnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'BEST'
language = sy-langu
name = thread-tdname
object = 'MATERIAL'
TABLES
lines = it_tlines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
*Loop on it_tlines where long text is coming .
LOOP AT it_tlines.
IF sy-subrc = 0.
p_index = sy-tabix.
IF p_index = 1.
int_out_new-tdline1 = it_tlines-tdline.
ELSEIF p_index = 2.
int_out_new-tdline2 = it_tlines-tdline.
ELSEIF p_index = 3.
int_out_new-tdline3 = it_tlines-tdline.
ELSEIF p_index = 4.
int_out_new-tdline4 = it_tlines-tdline.
ELSEIF p_index = 5.
int_out_new-tdline5 = it_tlines-tdline.
ELSEIF p_index = 6.
int_out_new-tdline6 = it_tlines-tdline.
ELSEIF p_index = 7.
int_out_new-tdline7 = it_tlines-tdline.
ELSEIF p_index = 8.
int_out_new-tdline8 = it_tlines-tdline.
ELSEIF p_index = 9.
int_out_new-tdline9 = it_tlines-tdline.
ELSEIF p_index GE 10.
int_out_new-tdline10 = it_tlines-tdline.
ENDIF.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM int_out .
APPEND int_out_new.
CLEAR int_out_new.
ENDLOOP.
Field Catalog
***MATERIAL NO no
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'WERKS'.
int_fcat-reptext_ddic = 'Plant'.
APPEND int_fcat .
***MATERIAL NO no
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'MATNR'.
int_fcat-reptext_ddic = 'Material N0'.
APPEND int_fcat .
*material Short Description
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'MAKTX'.
int_fcat-reptext_ddic = 'Material Short Description'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '45'.
APPEND int_fcat .
Material Long Description1
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE1'.
int_fcat-reptext_ddic = 'Material Long Description1'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description2
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE2'.
int_fcat-reptext_ddic = 'Material Long Description2'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description3
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE3'.
int_fcat-reptext_ddic = 'Material Long Description3'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description4
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE4'.
int_fcat-reptext_ddic = 'Material Long Description4'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description5
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE5'.
int_fcat-reptext_ddic = 'Material Long Description5'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description5
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE5'.
int_fcat-reptext_ddic = 'Material Long Description5'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description5
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE5'.
int_fcat-reptext_ddic = 'Material Long Description5'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description6
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE6'.
int_fcat-reptext_ddic = 'Material Long Description6'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description7
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE7'.
int_fcat-reptext_ddic = 'Material Long Description7'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description8
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE8'.
int_fcat-reptext_ddic = 'Material Long Description8'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description9
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE9'.
int_fcat-reptext_ddic = 'Material Long Description9'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
Material Long Description10
int_fcat-tabname = 'INT_OUT_NEW'.
int_fcat-fieldname = 'TDLINE10'.
int_fcat-reptext_ddic = 'Material Long Description10'.
int_fcat-datatype = 'CHAR'.
int_fcat-outputlen = '75'.
APPEND int_fcat .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = int_fcat[]
TABLES
t_outtab = int_out_new
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "display_data
Regards
Nik.
2007 Jul 29 4:56 AM
Nikhil,
Instead of declaring 10 lines, please declare a variable of type STRING.
Then append each line of your material text and concatenate it into the string.
Then you can comfartably have one long text and have it displayed to the user.
Please let us know if any further information is required.
Thanks
Ganesh.S
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |