Dynamic ALV Title
Hello Experts,
Please suggest how to generate dynamic ALV title for dynamic alv output.
Scenario: My ALV output is dynamic based on custom table. We have maintained 10 fields in custom table. In selection screen one of the parameter is number.
If i enter 2 or more than 2 accordingly my fieldcatlog will be prepared with same fields. But it will be mulitiple based on selection screen.
I have achieved till this part, now i need to generate title for each set of 10 columns.
Best example:
ALV output:
Title 1 Title2 Title3
A B C D E F G H I J | A B C D E F G H I J | A B C D E F G H I J |
I hope you all understand my problem and i appreciate your answers....
Thanks
Cris
Dear,
Use the below report code to print your dynamic coloumn in alv grid.
below just go through the use of variable w_bom for text,u will use single varible w_bom but clear it b4
printing it again. on the conditional base header will come in w_bom and print in fieldcatalog.
operate all operation b4 putting the text in fieldcatalog.
jus go through the code and you may ask any clarificaiton regarading that.
loop at i_fldcat into x_fldcat WHERE
fieldname = 'IDNRK' or
fieldname = 'MAKTX' or
fieldname = 'MEINS' or
FIELDNAME = 'MENGE1' OR
FIELDNAME = 'MENGE2' OR
FIELDNAME = 'MENGE3' OR
FIELDNAME = 'MENGE4' OR
FIELDNAME = 'MENGE5' OR
FIELDNAME = 'MENGE6' OR
FIELDNAME = 'MENGE7' OR
FIELDNAME = 'MENGE8'.
if stlal-low ne ''.
if x_fldcat-fieldname = 'IDNRK'.
x_fldcat-seltext_l = 'Component'.
x_fldcat-outputlen = 25.
x_fldcat-reptext_ddic = 'Component'.
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'MAKTX'.
x_fldcat-seltext_l = 'Component Description'.
x_fldcat-outputlen = 25.
x_fldcat-reptext_ddic = 'Component Description'.
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'MEINS'.
x_fldcat-seltext_l = 'UOM'.
x_fldcat-reptext_ddic = 'UOM'.
x_fldcat-ddictxt = c_l.
endif.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE1'.
read table t_stas1 with key stlal = '01'.
if sy-subrc NE 0.
x_fldcat-no_out = 'X'.
X_FLDCAT-TECH = 'X'.
ELSE.
PERFORM VAR_BOM USING T_STAS1-STLAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
endif.
ENDIF.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE2'.
read table t_stas1 with key stlal = '02'.
if sy-subrc NE 0.
x_fldcat-no_out = 'X'.
ELSE.
PERFORM VAR_BOM USING T_STAS1-STLAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
endif.
ENDIF.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE3'.
read table t_stas1 with key stlal = '03'.
if sy-subrc NE 0.
x_fldcat-no_out = 'X'.
ELSE.
PERFORM VAR_BOM USING T_STAS1-STLAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
endif.
ENDIF.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE4'.
read table t_stas1 with key stlal = '04'.
if sy-subrc NE 0.
x_fldcat-no_out = 'X'.
ELSE.
PERFORM VAR_BOM USING T_STAS1-STLAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
endif.
ENDIF.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE5'.
read table t_stas1 with key stlal = '05'.
if sy-subrc NE 0.
x_fldcat-no_out = 'X'.
ELSE.
PERFORM VAR_BOM USING T_STAS1-STLAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
ENDIF.
endif.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE6'.
read table t_stas1 with key stlal = '06'.
if sy-subrc NE 0.
x_fldcat-no_out = 'X'.
ELSE.
PERFORM VAR_BOM USING 6.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
ENDIF.
endif.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE7'.
read table t_stas1 with key stlal = '07'.
if sy-subrc NE 0.
x_fldcat-no_out = 'X'.
ELSE.
PERFORM VAR_BOM USING 7.
if sy-subrc = 0.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
ENDIF.
endif.
ENDIF.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE8'.
read table t_stas1 with key stlal = '08'.
if sy-subrc NE 0.
x_fldcat-no_out = 'X'.
ELSE.
PERFORM VAR_BOM USING 8.
if sy-subrc = 0.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
ENDIF.
endif.
ENDIF.
modify i_fldcat from x_fldcat index T_INDEX.
T_INDEX = T_INDEX + 1.
CLEAR X_FLDCAT.
ELSE.
if x_fldcat-fieldname = 'IDNRK'.
x_fldcat-seltext_l = 'Component'.
x_fldcat-reptext_ddic = 'Component'.
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'MAKTX'.
x_fldcat-seltext_l = 'Component Description'.
x_fldcat-outputlen = 25.
x_fldcat-reptext_ddic = 'Component Description'.
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'MEINS'.
x_fldcat-seltext_l = 'UOM'.
x_fldcat-reptext_ddic = 'UOM'.
x_fldcat-ddictxt = c_l.
endif.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE1'.
PERFORM VAR_BOM USING 1.
if T_BOM-STKTX IS NOT INITIAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
else.
X_FLDCAT-NO_OUT = 'X'.
X_FLDCAT-TECH = 'X'.
endif.
ENDIF.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE2'.
PERFORM VAR_BOM USING 2.
if T_BOM-STKTX IS NOT INITIAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
else.
X_FLDCAT-NO_OUT = 'X'.
X_FLDCAT-TECH = 'X'.
endif.
ENDIF.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE3'.
PERFORM VAR_BOM USING 3.
if T_BOM-STKTX IS NOT INITIAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
else.
X_FLDCAT-NO_OUT = 'X'.
X_FLDCAT-TECH = 'X'.
endif.
ENDIF.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE4'.
PERFORM VAR_BOM USING 4.
if T_BOM-STKTX IS NOT INITIAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
else.
X_FLDCAT-NO_OUT = 'X'.
X_FLDCAT-TECH = 'X'.
endif.
ENDIF.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE5'.
PERFORM VAR_BOM USING 5.
if T_BOM-STKTX IS NOT INITIAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
else.
X_FLDCAT-NO_OUT = 'X'.
X_FLDCAT-TECH = 'X'.
ENDIF.
endif.
CLEAR T_BOM-STLST.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE6'.
PERFORM VAR_BOM USING 6.
if T_BOM-STKTX IS NOT INITIAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
else.
X_FLDCAT-NO_OUT = 'X'.
X_FLDCAT-TECH = 'X'.
endif.
endif.
CLEAR T_BOM-STLST.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE7'.
PERFORM VAR_BOM USING 7.
if T_BOM-STKTX IS NOT INITIAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
else.
X_FLDCAT-NO_OUT = 'X'.
X_FLDCAT-TECH = 'X'.
endif.
endif.
clear t_bom-STLST.
CLEAR W_BOM.
if x_fldcat-fieldname = 'MENGE8'.
PERFORM VAR_BOM USING 8.
if T_BOM-STKTX IS NOT INITIAL.
CONCATENATE '' T_BOM-STKTX INTO W_BOM separated BY SPACE.
IF T_BOM-STLST = '1'.
X_FLDCAT-EMPHASIZE = 'C511'.
ENDIF.
x_fldcat-seltext_l = W_BOM.
x_fldcat-reptext_ddic = W_BOM.
x_fldcat-ddictxt = c_l.
else.
X_FLDCAT-NO_OUT = 'X'.
X_FLDCAT-TECH = 'X'.
endif.
endif.
modify i_fldcat from x_fldcat index sy-tabix.
CLEAR X_FLDCAT.
endif.
endloop.
endform. " build_field_catalog
FORM VAR_BOM USING P_CNT.
if NOT stlal-low = ''.
LOOP AT T_BOM where stlal = t_stas1-stlal .
READ TABLE T_BOM with key stlal = t_stas1-stlal.
IF SY-SUBRC <> 0.
T_BOM-STKTX = ''.
clear t_bom.
exit.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT T_BOM .
READ TABLE T_BOM INDEX P_CNT.
IF SY-SUBRC <> 0.
T_BOM-STKTX = ''.
clear t_bom.
exit.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "VAR_BOM
form call_list_viewer.
delete T_FINAL where IDNRK eq ''.
data : T1_MAST like T_MAST occurs 0 with header line.
data : t_stas like STAS occurs 0 with header line.
data : t_stko like stko occurs 0 with header line.
clear : t_stas[],t_stas,t1_STPO,t1_STPO[],t_stko,t_stko[],t1_mast,
t1_mast[].
SELECT MATNR WERKS STLAN STLNR STLAL ANDAT
INTO CORRESPONDING FIELDS OF TABLE T1_MAST
FROM MAST WHERE MATNR = MATNR AND WERKS = WERKS
AND STLAN = STLAN AND STLAL IN STLAL.
if not T1_MAST[] is initial.
read table T1_MAST index 1.
select * from stas into table t_stas
where stlnr = T1_MAST-STLNR
and stlal in stlal
and STLTY NE 'D'.
endif.
IF NOT T1_MAST[] IS INITIAL.
SELECT STLTY STLNR STLKN STPOZ ANDAT IDNRK POSTP POSNR
MEINS MENGE FMENG POTX1 OBJTY STVKN
INTO CORRESPONDING FIELDS OF TABLE T1_STPO
FROM STPO
FOR ALL ENTRIES IN T1_MAST
WHERE STLNR = T1_MAST-STLNR
AND FMENG = 'X'.
ENDIF.
sort t_stas by STLAL STVKN.
sort t_stas by STLNR STLAL.
loop at T1_MAST.
loop at t_stas where STLNR = T1_MAST-STLNR
and STLAL = T1_MAST-STLAL.
LOOP AT T1_STPO where STLKN = t_stas-STLKN.
IF T1_MAST-STLAL = 01.
T_FINAL-MAKTX = T1_STPO-POTX1.
T_FINAL-MEINS = T1_STPO-MEINS.
T_FINAL-MENGE1 = T1_STPO-MENGE.
ELSEIF T1_MAST-STLAL = 02.
T_FINAL-MAKTX = T1_STPO-POTX1.
T_FINAL-MEINS = T1_STPO-MEINS.
T_FINAL-MENGE2 = T1_STPO-MENGE.
ELSEIF T1_MAST-STLAL = 03.
T_FINAL-MAKTX = T1_STPO-POTX1.
T_FINAL-MEINS = T1_STPO-MEINS.
T_FINAL-MENGE3 = T1_STPO-MENGE.
ELSEIF T1_MAST-STLAL = 04.
T_FINAL-MAKTX = T1_STPO-POTX1.
T_FINAL-MEINS = T1_STPO-MEINS.
T_FINAL-MENGE4 = T1_STPO-MENGE.
ELSEIF T1_MAST-STLAL = 05.
T_FINAL-MAKTX = T1_STPO-POTX1.
T_FINAL-MEINS = T1_STPO-MEINS.
T_FINAL-MENGE5 = T1_STPO-MENGE.
ELSEIF T1_MAST-STLAL = 06.
T_FINAL-MAKTX = T1_STPO-POTX1.
T_FINAL-MEINS = T1_STPO-MEINS.
T_FINAL-MENGE6 = T1_STPO-MENGE.
ELSEIF T1_MAST-STLAL = 07.
T_FINAL-MAKTX = T1_STPO-POTX1.
T_FINAL-MEINS = T1_STPO-MEINS.
T_FINAL-MENGE7 = T1_STPO-MENGE.
ELSEIF T1_MAST-STLAL = 08.
T_FINAL-MAKTX = T1_STPO-POTX1.
T_FINAL-MEINS = T1_STPO-MEINS.
T_FINAL-MENGE8 = T1_STPO-MENGE.
ENDIF.
read table T_FINAL with key MAKTX = T1_STPO-POTX1.
if sy-subrc ne 0.
APPEND T_FINAL.
clear T_FINAL.
elseif T1_MAST-STLAL = 08.
T_FINAL-MAKTX = T1_STPO-POTX1.
T_FINAL-MEINS = T1_STPO-MEINS.
T_FINAL-MENGE8 = T1_STPO-MENGE.
MODIFY T_FINAL FROM T_FINAL TRANSPORTING MENGE8
WHERE MAKTX = T1_STPO-POTX1.
clear T_FINAL.
endif.
endif.
endloop.
endloop.
clear : T_FINAL.
endloop.
sort T_FINAL by IDNRK descending.
*end 09.07.2007
*endded
Thanks and regards
vijay dwivedi
Similar Messages
-
Dynamically ALV Titles Using Events - How To
Dear All,
There is a selection screen. Depending upon the selection, there will be output in ALV grid or list. This output doesn't contain any field of selection.
So the output must be grouped on the basis of selection as their common title.
Eg. If model and type are in selection screen then output something like
Model No. 1 Type No. 2
ALV Grid for Model 1 and Type 2
Model No. 3 Type No. 4
ALV Grid for Model 3 and Type 4
How to use ALV Events to process the data dynamically for the titles as in above case the numbers 1, 2 ,3 & 4 are present in the output table which is passed to ALV for display.
Thanks & Regards,
Sapna Modi.Hi Sapna
To set title you can fill a structure of type <b>"LVC_S_LAYO"</b> (the field gridtitle) and use the method <b>"set_frontend_layout"</b>. You can get the current layout structure using the method <b>"get_frontend_layout"</b>.
To set column headers you can use to get and set the fieldcatalog at any instance of the runtime. For this you can use <b>"set_frontend_fieldcatalog"</b> and <b>"get_frontend_fieldcatalog"</b>. At the field catalog, you can set titles for columns using <i>"coltext", "scrtext_s", "scrtext_m", "scrtext_t"</i> .
For more information you can refer to the tutorial <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference For ALV Grid Control"</a>.
*--Serdar
[email protected] -
Problem in Data Display in Dynamic ALV Report
Hi all,
I am developing a Dynamic ALV report where I want display material batch (zjpack_base-charg) in column and Material (zjpack_base-matnr) & Qty (Zjpack_base-netwr) field row wise.My intention is to show report datewise for a material how many batch developed with there qty.I am sending you the code which i already wrote.Here column is developed batchwise but I am not able to show the qty against each batch.Please see my code and guide me how to display.
REPORT zdynamic_test .
*REPORT ztest_notepad.
*& Declarations
*Type-pools
TYPE-POOLS: slis.
*TABLES
TABLES: zjpack_base.
*Types
TYPES:
ty_fcat TYPE lvc_s_fcat,
ty_fcatalog TYPE slis_fieldcat_alv.
*Work areas
DATA:
wa_fcat TYPE ty_fcat,
wa_fcatalog TYPE ty_fcatalog.
*Internal tables
DATA:
it_fcat TYPE STANDARD TABLE OF ty_fcat,
it_fcatalog TYPE STANDARD TABLE OF ty_fcatalog.
*Type reference
DATA:
it_dyn_tab TYPE REF TO data,
wa_newline TYPE REF TO data.
*INTERNAL TABLE
DATA: BEGIN OF it_itab OCCURS 0.
INCLUDE STRUCTURE zjpack_base.
DATA: END OF it_itab.
*Filed symbols
FIELD-SYMBOLS:
<gt_table> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> TYPE ANY,
<l_field> TYPE ANY.
*Variables
DATA:
l_fieldname TYPE lvc_s_fcat-fieldname,
l_tabname TYPE lvc_s_fcat-tabname,
l_fieldtext TYPE lvc_s_fcat-seltext,
l_index TYPE char2.
"Selection-screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s11 .
SELECT-OPTIONS:s_matnr FOR zjpack_base-matnr.
SELECT-OPTIONS:s_charg FOR zjpack_base-charg.
SELECT-OPTIONS:s_fdate FOR zjpack_base-fdate .
SELECTION-SCREEN END OF BLOCK b1.
PARAMETERS:
p_colms TYPE i.
*& start-of-selection.
START-OF-SELECTION.
PERFORM select_data.
PERFORM build_fieldcat.
PERFORM create_dynamic_table.
DO 20 TIMES.
DO p_colms TIMES.
l_index = sy-index.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
<l_field> = sy-index.
ENDDO.
INSERT <fs_dyntable> INTO TABLE <gt_table>.
ENDDO.
LOOP AT it_itab.
l_index = sy-tabix.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
<l_field> = it_itab-matnr.
INSERT <fs_dyntable> INTO TABLE <gt_table>.
ENDLOOP.
LOOP AT it_fcat INTO wa_fcat.
PERFORM fieldcatalog1 USING: wa_fcat-fieldname
wa_fcat-tabname
wa_fcat-seltext.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZTEST_NOTEPAD'
it_fieldcat = it_fcatalog
TABLES
t_outtab = <gt_table>.
*& Form BUILD_FIELDCAT
FORM build_fieldcat .
CLEAR: l_fieldname,
l_tabname,
l_fieldtext,
l_index.
DO p_colms TIMES.
CLEAR l_index.
l_index = sy-index.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
CONCATENATE 'Field' l_index INTO l_fieldtext.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
ENDDO.
ENDFORM. " BUILD_FIELDCAT
*& Form CREATE_DYNAMIC_TABLE
FORM create_dynamic_table .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat
IMPORTING
ep_table = it_dyn_tab.
ASSIGN it_dyn_tab->* TO <gt_table>.
Create dynamic work area and assign to FS
CREATE DATA wa_newline LIKE LINE OF <gt_table>.
ASSIGN wa_newline->* TO <fs_dyntable>.
ENDFORM. " CREATE_DYNAMIC_TABLE
*& Form FIELDCATALOG
FORM fieldcatalog USING field table f_txt.
wa_fcat-fieldname = field.
wa_fcat-tabname = table.
wa_fcat-seltext = f_txt.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDFORM. " FIELDCATALOG
*& Form FIELDCATALOG1
FORM fieldcatalog1 USING field table f_txt.
wa_fcatalog-fieldname = field.
wa_fcatalog-tabname = table.
wa_fcatalog-seltext_m = f_txt.
APPEND wa_fcatalog TO it_fcatalog.
CLEAR wa_fcatalog.
ENDFORM. " FIELDCATALOG1
*& Form SELECT_DATA
text
--> p1 text
<-- p2 text
FORM select_data .
DATA: v_srlno TYPE i.
SELECT matnr charg blqty
INTO CORRESPONDING FIELDS OF it_itab
FROM zjpack_base
WHERE matnr IN s_matnr
AND charg IN s_charg
AND fdate IN s_fdate.
COLLECT it_itab.
ENDSELECT.
v_srlno.
LOOP AT it_itab.
v_srlno = v_srlno + 1.
ENDLOOP.
CLEAR: l_fieldname,
l_tabname,
l_fieldtext,
l_index.
1st Field
l_index = sy-tabix.
CONCATENATE 'FIELD' '1' INTO l_fieldname.
l_fieldtext = 'MATNR'.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
Other fields
LOOP AT it_itab.
CLEAR l_index.
l_index = sy-tabix + 1.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
CONCATENATE 'CHARG-' it_itab-charg INTO l_fieldtext.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
ENDLOOP.
Please guide me how my problem will solve.
Thanks & Regards
NirmalHi all, I am developing a Dynamic ALV report where I want display material batch (zjpack_base-charg) in column and Material (zjpack_base-matnr) & Qty (Zjpack_base-netwr) field row wise.My intention is to show report datewise for a material how many batch developed with there qty.I am sending you the code which i already wrote.Here column is developed batchwise but I am not able to show the qty against each batch.Please see my code and guide me how to display.
*& Report ZDYNAMIC_TEST *
REPORT zdynamic_test .
*REPORT ztest_notepad.
*& Declarations
*Type-pools
TYPE-POOLS: slis.
*TABLES
TABLES: zjpack_base.
*Types
TYPES:
ty_fcat TYPE lvc_s_fcat,
ty_fcatalog TYPE slis_fieldcat_alv.
*Work areas
DATA:
wa_fcat TYPE ty_fcat,
wa_fcatalog TYPE ty_fcatalog.
*Internal tables
DATA:
it_fcat TYPE STANDARD TABLE OF ty_fcat,
it_fcatalog TYPE STANDARD TABLE OF ty_fcatalog.
*Type reference
DATA:
it_dyn_tab TYPE REF TO data,
wa_newline TYPE REF TO data.
*INTERNAL TABLE
DATA: BEGIN OF it_itab OCCURS 0.
INCLUDE STRUCTURE zjpack_base.
DATA: END OF it_itab.
*Filed symbols
FIELD-SYMBOLS:
<gt_table> TYPE STANDARD TABLE,
<fs_dyntable>,
<fs_fldval> TYPE ANY,
<l_field> TYPE ANY.
*Variables
DATA:
l_fieldname TYPE lvc_s_fcat-fieldname,
l_tabname TYPE lvc_s_fcat-tabname,
l_fieldtext TYPE lvc_s_fcat-seltext,
l_index TYPE char2.
"Selection-screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-s11 .
SELECT-OPTIONS:s_matnr FOR zjpack_base-matnr.
SELECT-OPTIONS:s_charg FOR zjpack_base-charg.
SELECT-OPTIONS:s_fdate FOR zjpack_base-fdate .
SELECTION-SCREEN END OF BLOCK b1.
PARAMETERS:
p_colms TYPE i.
*& start-of-selection.
START-OF-SELECTION.
PERFORM select_data.
PERFORM build_fieldcat.
PERFORM create_dynamic_table.
* DO 20 TIMES.
* DO p_colms TIMES.
* l_index = sy-index.
* CONCATENATE 'FIELD' l_index INTO l_fieldname.
* ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
* <l_field> = sy-index.
* ENDDO.
* INSERT <fs_dyntable> INTO TABLE <gt_table>.
* ENDDO.
LOOP AT it_itab.
l_index = sy-tabix.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
ASSIGN COMPONENT l_fieldname OF STRUCTURE <fs_dyntable> TO <l_field>.
<l_field> = it_itab-matnr.
INSERT <fs_dyntable> INTO TABLE <gt_table>.
ENDLOOP.
LOOP AT it_fcat INTO wa_fcat.
PERFORM fieldcatalog1 USING: wa_fcat-fieldname
wa_fcat-tabname
wa_fcat-seltext.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZTEST_NOTEPAD'
it_fieldcat = it_fcatalog
TABLES
t_outtab = <gt_table>.
*& Form BUILD_FIELDCAT
FORM build_fieldcat .
* CLEAR: l_fieldname,
* l_tabname,
* l_fieldtext,
* l_index.
* DO p_colms TIMES.
* CLEAR l_index.
* l_index = sy-index.
* CONCATENATE 'FIELD' l_index INTO l_fieldname.
* CONCATENATE 'Field' l_index INTO l_fieldtext.
* l_tabname = '<GT_TABLE>'.
* PERFORM fieldcatalog USING: l_fieldname
* l_tabname
* l_fieldtext.
* ENDDO.
ENDFORM. " BUILD_FIELDCAT
*& Form CREATE_DYNAMIC_TABLE
FORM create_dynamic_table .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat
IMPORTING
ep_table = it_dyn_tab.
ASSIGN it_dyn_tab->* TO <gt_table>.
* Create dynamic work area and assign to FS
CREATE DATA wa_newline LIKE LINE OF <gt_table>.
ASSIGN wa_newline->* TO <fs_dyntable>.
ENDFORM. " CREATE_DYNAMIC_TABLE
*& Form FIELDCATALOG
FORM fieldcatalog USING field table f_txt.
wa_fcat-fieldname = field.
wa_fcat-tabname = table.
wa_fcat-seltext = f_txt.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
ENDFORM. " FIELDCATALOG
*& Form FIELDCATALOG1
FORM fieldcatalog1 USING field table f_txt.
wa_fcatalog-fieldname = field.
wa_fcatalog-tabname = table.
wa_fcatalog-seltext_m = f_txt.
APPEND wa_fcatalog TO it_fcatalog.
CLEAR wa_fcatalog.
ENDFORM. " FIELDCATALOG1
*& Form SELECT_DATA
* text
* --> p1 text
* <-- p2 text
FORM select_data .
* DATA: v_srlno TYPE i.
SELECT matnr charg blqty
INTO CORRESPONDING FIELDS OF it_itab
FROM zjpack_base
WHERE matnr IN s_matnr
AND charg IN s_charg
AND fdate IN s_fdate.
COLLECT it_itab.
ENDSELECT.
* v_srlno.
* LOOP AT it_itab.
* v_srlno = v_srlno + 1.
* ENDLOOP.
CLEAR: l_fieldname,
l_tabname,
l_fieldtext,
l_index.
* 1st Field
* l_index = sy-tabix.
CONCATENATE 'FIELD' '1' INTO l_fieldname.
l_fieldtext = 'MATNR'.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
* Other fields
LOOP AT it_itab.
CLEAR l_index.
l_index = sy-tabix + 1.
CONCATENATE 'FIELD' l_index INTO l_fieldname.
CONCATENATE 'CHARG-' it_itab-charg INTO l_fieldtext.
l_tabname = '<GT_TABLE>'.
PERFORM fieldcatalog USING: l_fieldname
l_tabname
l_fieldtext.
ENDLOOP.
ENDFORM. " SELECT_DATA -
GOS - Generic Object Services - Change dynamically the title of attachments
Dear Experts,
how can I change dynamically the title of the single attachment in the attachment-list of cl_gos_manager?
I hope you can help me.
Thanks in advance.Thanks for reply.
I solved the problem by the following way:
- Function ARCHIV_GET_CONNECTIONS for getting all linked documents
- Showing list in popup with ALV-Grid
- SET HANDLER handle_double_click
- Function ALINK_DOCUMETS_DISPLAY_MIX for viewing selected document on popup
Marco -
I want to create dynamic ALV report
Hi great abapers,
I want to create dynamic ALV report.Please help me.
Regards,
BillaHi,
Please check the code below:
REPORT YMMR_PALLET_OVERVIEW MESSAGE-ID Y_MESSAGE_0001.
Short description:
To Display and sum up the Quantity of scanned materials on pallet for*
each Shipment number for the Packaging Materials. *
TYPE-POOLS : SLIS.
TABLES: YYLE0003. " Scanned SSCC No.
--Structure Declaration--
Structure for Shipment No. and Date.
TYPES : BEGIN OF T_VTTK_TAB ,
TKNUM LIKE VTTK-TKNUM, " Shipment number
ERDAT LIKE VTTK-ERDAT, " created Date
END OF T_VTTK_TAB .
Structure for Shipment No., Packaging Materials and Date.
TYPES: BEGIN OF T_ITAB2,
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
QUANTITY TYPE P,
ERDAT LIKE YYLE0003-ERDAT, " created Date
COUNT TYPE I,
END OF T_ITAB2.
Structure for Shipment No. and Packaging Materials.
TYPES: BEGIN OF T_ITAB3,
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
QUANTITY TYPE P, " Quantity
END OF T_ITAB3.
--Internal table Declaration--
*Internal tables for the above Declared structures
DATA: G_VTTK_TAB TYPE TABLE OF T_VTTK_TAB,
G_ITAB5_TAB TYPE TABLE OF T_ITAB2,
G_ITAB4_TAB TYPE TABLE OF T_ITAB3,
G_ITAB3_TAB TYPE TABLE OF T_ITAB2. "#EC NEEDED
*Internal table Holding Shipment No.and quantity
DATA: BEGIN OF G_TOTAL_TAB OCCURS 0 ,
TKNUM TYPE YYLE0003-TKNUM, " Shipment number
QUANTITY TYPE P,
COUNT TYPE I,
END OF G_TOTAL_TAB .
*Internal table for selection screen data
DATA: BEGIN OF G_SCANDATA_TAB OCCURS 0,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
EXIDV TYPE EXIDV, " External Handling Unit
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
END OF G_SCANDATA_TAB.
DATA: BEGIN OF ST_SCANDATA_TAB,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
EXIDV TYPE EXIDV, " External Handling Unit
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
END OF ST_SCANDATA_TAB.
DATA: BEGIN OF G_SCANDATA_COUNT_TAB OCCURS 0,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
COUNT TYPE I,
END OF G_SCANDATA_COUNT_TAB.
DATA: L_COUNT TYPE I.
*Internal table for Packaging Materials and quantity
DATA: BEGIN OF G_ITAB6_TAB OCCURS 0,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
QUANTITY TYPE P, " Quantity
END OF G_ITAB6_TAB.
*- Field catalog
DATA: L_ALV_CAT1_TAB TYPE TABLE OF LVC_S_FCAT.
--Work area Declaration--
DATA: WA_VTTK TYPE T_VTTK_TAB,
WA_ITAB3 TYPE T_ITAB2,
WA_ITAB5 TYPE T_ITAB2,
WA_ITAB4 TYPE T_ITAB3,
WA_ITAB1 LIKE G_SCANDATA_TAB,
WA_ALV_CAT1 LIKE LINE OF L_ALV_CAT1_TAB.
----Variable Defnition -
DATA: G_CUSTOM_CONTAINER_0100 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_ALV_GRID_0100 TYPE REF TO CL_GUI_ALV_GRID,
G_CONTAINER_0100 TYPE SCRFNAME VALUE 'LIST',
G_MYLAYOUT TYPE LVC_S_LAYO, "#EC NEEDED
G_WA TYPE REF TO DATA.
DATA: G_VAR TYPE I, " No of records
G_VAR1 TYPE CHAR20. " Variable
--field symbols Declaration--
FIELD-SYMBOLS : <F_FS> TYPE TABLE,
<F_FS3> TYPE ANY,
<F_FS4> TYPE ANY,
<F_FS5> TYPE ANY,
<F_WA> TYPE ANY,
<F_FS15> TYPE ANY,
<F_FS16> TYPE SY-DATUM,
<F_FS2> TYPE T_ITAB2,
<F_FS6> TYPE ANY,
<F_FS7> TYPE ANY,
<F_FS12> TYPE ANY,
<F_FS13> TYPE ANY.
--Selection Parameters--
SELECTION-SCREEN: BEGIN OF BLOCK BLCK01 WITH FRAME TITLE TEXT-000.
"Select options
SELECT-OPTIONS :
S_TKNUM FOR YYLE0003-TKNUM , " Shipment number
S_YYREF FOR YYLE0003-YY_REFERENCE, " Packing reference
S_YYREFT FOR YYLE0003-YY_REFTP, " Reference type
S_EXIDV FOR YYLE0003-EXIDV, " External HU
S_MATNR FOR YYLE0003-MATNR, " Material number
S_VBELN FOR YYLE0003-VBELN, " SD number
S_POSNR FOR YYLE0003-POSNR, " Item number
S_LGTOR FOR YYLE0003-LGTOR, " Door for Wr Hs No
S_VHILM FOR YYLE0003-VHILM, " Packaging Mat
S_YYMEIN FOR YYLE0003-YY_MEINH, " Indicator for UOM
S_QUANTI FOR YYLE0003-QUANTITY, " Quantity
S_YCHECK FOR YYLE0003-YYCHECKED, " Destination_door
S_STATUS FOR YYLE0003-STATUS, " Packing status
S_STASHI FOR YYLE0003-STATUSSHIPTO, " Status on ship-to
S_LOADTR FOR YYLE0003-LOADTRUCK, " Load truck
S_ERDAT FOR YYLE0003-ERDAT , " Date
S_ERZET FOR YYLE0003-ERZET, " Entry time
S_AEDAT FOR YYLE0003-AEDAT, " Last changed on
S_ERNAM FOR YYLE0003-ERNAM, " Name of Person
S_AEZET FOR YYLE0003-AEZET, " Time last change
S_AENAM FOR YYLE0003-AENAM. " Name of person
SELECTION-SCREEN: END OF BLOCK BLCK01.
--INITIALIZATION--
INITIALIZATION.
Clear the variables and workarea
CLEAR :G_VAR,
G_VAR1,
WA_VTTK,
WA_ITAB3,
WA_ITAB5,
WA_ITAB4,
WA_ITAB1,
WA_VTTK,
WA_ITAB3,
WA_ITAB5,
WA_ITAB4,
WA_ITAB1.
--AT SELECTION-SCREEN--
AT SELECTION-SCREEN.
To validate the data entered in selection screen
PERFORM SUB_VALIDATE.
--START-OF-SELECTION--
START-OF-SELECTION.
*To fetch the data from table yyle0003
PERFORM GET_INPUT_DATA.
*To create the Dynamic Field Catalog
PERFORM GET_FIELDCAT.
To populate the data to final table
PERFORM GET_FINAL_DATA.
MODULE status_0100 OUTPUT *
MODULE STATUS_0100 OUTPUT.
*set title bar and PF status.
SET PF-STATUS 'ZVKS'.
SET TITLEBAR 'ZVKS'.
CHECK SY-UCOMM IS INITIAL.
SORT G_SCANDATA_TAB BY TKNUM VHILM.
*Create object for Custom container
CREATE OBJECT G_CUSTOM_CONTAINER_0100
EXPORTING
CONTAINER_NAME = G_CONTAINER_0100
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
*Create object for ALV grid
CREATE OBJECT G_ALV_GRID_0100
EXPORTING I_PARENT = G_CUSTOM_CONTAINER_0100.
G_MYLAYOUT-GRID_TITLE = 'Display Scanning data'.
*Call method for table Display
CALL METHOD G_ALV_GRID_0100->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = <F_FS>
IT_FIELDCATALOG = L_ALV_CAT1_TAB
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
User Interaction
MODULE USER_COMMAND_0100 INPUT.
CALL METHOD CL_GUI_CFW=>DISPATCH.
*To exit , back or cancel
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form get_input_data
This sub routine will get the data from yyle0003 table.
FORM GET_INPUT_DATA.
CONSTANTS: C_DOT TYPE C VALUE '.',
C_CHAR TYPE C VALUE 'D'.
CLEAR G_SCANDATA_TAB.
Get the data from yyle0003
SELECT VHILM " Packaging Materials
EXIDV " External Handling Unit
TKNUM " Shipment number
QUANTITY " Quantity
FROM YYLE0003
INTO TABLE G_SCANDATA_TAB
WHERE TKNUM IN S_TKNUM " Shipment number
AND YY_REFERENCE IN S_YYREF " Packing reference
AND YY_REFTP IN S_YYREFT " Reference type
AND EXIDV IN S_EXIDV " External Handling Unit
AND MATNR IN S_MATNR " Material number
AND VBELN IN S_VBELN " SD number
AND POSNR IN S_POSNR " Item number
AND LGTOR IN S_LGTOR " Door for warehouse No
AND VHILM IN S_VHILM " Packaging Materials
AND YY_MEINH IN S_YYMEIN " Indicator for UOM
AND QUANTITY IN S_QUANTI " Quantity
AND YYCHECKED IN S_YCHECK " Destination_door
AND STATUS IN S_STATUS " Packing status
AND STATUSSHIPTO IN S_STASHI " Status on ship-to
AND LOADTRUCK IN S_LOADTR " Load truck
AND ERDAT IN S_ERDAT " Date
AND ERZET IN S_ERZET " Entry time
AND AEDAT IN S_AEDAT " Last changed on
AND ERNAM IN S_ERNAM " Name of Person
AND AEZET IN S_AEZET " Time last change
AND AENAM IN S_AENAM. " Name of person
If VHILM contains any Decimal '.', replace it with D
LOOP AT G_SCANDATA_TAB.
REPLACE C_DOT WITH C_CHAR INTO G_SCANDATA_TAB-VHILM.
IF SY-SUBRC = 0.
MODIFY G_SCANDATA_TAB TRANSPORTING VHILM.
ENDIF.
CLEAR G_SCANDATA_TAB.
ENDLOOP.
*To get the Shipment No Creation date from VTTK.
SELECT TKNUM
ERDAT
FROM VTTK
INTO TABLE G_VTTK_TAB
WHERE TKNUM IN S_TKNUM.
SORT G_SCANDATA_TAB BY VHILM EXIDV. "TKNUM VHILM.
*To get the repeatition of Pacakaging material for each Shipment.
*--- to find the count of packaging materials under each shipment
LOOP AT G_SCANDATA_TAB.
READ TABLE G_SCANDATA_TAB INTO ST_SCANDATA_TAB INDEX SY-TABIX.
AT END OF EXIDV.
L_COUNT = L_COUNT + 1.
MOVE-CORRESPONDING ST_SCANDATA_TAB TO G_SCANDATA_COUNT_TAB.
G_SCANDATA_COUNT_TAB-COUNT = L_COUNT.
CLEAR: ST_SCANDATA_TAB, L_COUNT.
COLLECT G_SCANDATA_COUNT_TAB.
ENDAT.
CLEAR : G_SCANDATA_TAB.
ENDLOOP.
ENDFORM. " get_input_data
*& Form sub_validate
*This subroutine will validate the data eneterd in the selection screen
FORM SUB_VALIDATE.
*Varaiable declaration for Shipment number
DATA: L_TKNUM TYPE YYLE0003-TKNUM."#EC NEEDED " Shipment number
*- Condition will not qualify all primary key (IDENT)
SELECT TKNUM FROM YYLE0003 UP TO 1 ROWS
INTO L_TKNUM "wa_scandata
WHERE TKNUM IN S_TKNUM " Shipment number
AND YY_REFERENCE IN S_YYREF " Packing reference
AND YY_REFTP IN S_YYREFT " Reference type
AND EXIDV IN S_EXIDV " External Handling Unit
AND MATNR IN S_MATNR " Material number
AND VBELN IN S_VBELN " SD number
AND POSNR IN S_POSNR " Item number
AND LGTOR IN S_LGTOR " Door for warehouse No
AND VHILM IN S_VHILM " Packaging Materials
AND YY_MEINH IN S_YYMEIN " Indicator for UOM
AND QUANTITY IN S_QUANTI " Quantity
AND YYCHECKED IN S_YCHECK " Destination_door
AND STATUS IN S_STATUS " Packing status
AND STATUSSHIPTO IN S_STASHI " Status on ship-to
AND LOADTRUCK IN S_LOADTR " Load truck
AND ERDAT IN S_ERDAT " Date
AND ERZET IN S_ERZET " Entry time
AND AEDAT IN S_AEDAT " Last changed on
AND ERNAM IN S_ERNAM " Name of Person
AND AEZET IN S_AEZET " Time last change
AND AENAM IN S_AENAM. " Name of person
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E987 . " No data found for these selection criterias
ENDIF.
ENDFORM. " sub_validate
*& Form get_fieldcat
Preparing Field catalog
FORM GET_FIELDCAT.
DATA: L_REF TYPE REF TO DATA,
L_I TYPE I. " Variable
CONSTANTS: C_CENTER TYPE C VALUE 'C'. " Center Justified
LOOP AT G_SCANDATA_TAB INTO WA_ITAB1.
MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB3.
APPEND WA_ITAB3 TO G_ITAB3_TAB.
MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB4.
COLLECT WA_ITAB4 INTO G_ITAB4_TAB.
*To sum up the qunatity field for each TKNUM.
AT END OF TKNUM.
SUM.
MOVE WA_ITAB1-TKNUM TO G_TOTAL_TAB-TKNUM.
MOVE WA_ITAB1-QUANTITY TO G_TOTAL_TAB-QUANTITY .
APPEND G_TOTAL_TAB.
CLEAR G_TOTAL_TAB.
ENDAT.
CLEAR : WA_ITAB1,
WA_ITAB3,
WA_ITAB4.
ENDLOOP.
*--- Begin of change - SKR.EXT - EBDK986377
SORT G_ITAB4_TAB BY TKNUM.
*--- End of change - SKR.EXT - EBDK986377
LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
MOVE-CORRESPONDING WA_ITAB4 TO WA_ITAB5.
MOVE-CORRESPONDING WA_ITAB4 TO G_ITAB6_TAB.
*---- to get the count
READ TABLE G_SCANDATA_COUNT_TAB WITH KEY TKNUM = WA_ITAB5-TKNUM
VHILM = WA_ITAB5-VHILM.
IF SY-SUBRC EQ 0.
WA_ITAB5-COUNT = G_SCANDATA_COUNT_TAB-COUNT.
ENDIF.
APPEND WA_ITAB5 TO G_ITAB5_TAB.
COLLECT G_ITAB6_TAB.
ENDLOOP.
CLEAR : WA_ITAB3.
SORT G_ITAB4_TAB BY TKNUM VHILM.
DELETE ADJACENT DUPLICATES FROM G_ITAB4_TAB COMPARING VHILM.
*To get the Number of fields to be displayed
DESCRIBE TABLE G_ITAB4_TAB LINES G_VAR.
L_I = '3'.
*Field catalog
WA_ALV_CAT1-FIELDNAME = 'TKNUM'(002).
WA_ALV_CAT1-COL_POS = 1.
WA_ALV_CAT1-COLTEXT ='ShipmentNo.'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR : WA_ALV_CAT1.
WA_ALV_CAT1-FIELDNAME = 'ERDAT'(003).
WA_ALV_CAT1-COL_POS = 2.
WA_ALV_CAT1-COLTEXT ='Creation_Date.'(005).
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR : WA_ALV_CAT1.
Create field catalog for each of VHILM
LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
IF G_VAR >= 1.
CONDENSE WA_ITAB4-VHILM NO-GAPS.
WA_ALV_CAT1-FIELDNAME = WA_ITAB4-VHILM. "l_fieldname.
WA_ALV_CAT1-COL_POS = L_I.
WA_ALV_CAT1-COLTEXT = WA_ITAB4-VHILM.
WA_ALV_CAT1-JUST = C_CENTER. "'C'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR WA_ALV_CAT1.
L_I = L_I + 1.
ENDIF.
*TOTAL-last column in the field catalog
AT LAST.
WA_ALV_CAT1-FIELDNAME = 'TOTAL'(004).
WA_ALV_CAT1-COL_POS = L_I.
WA_ALV_CAT1-COLTEXT = 'TOTAL'(004).
WA_ALV_CAT1-JUST = C_CENTER. " 'C'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR WA_ALV_CAT1.
ENDAT.
SORT L_ALV_CAT1_TAB BY FIELDNAME.
*Non of the field name should not get repeated
DELETE ADJACENT DUPLICATES FROM L_ALV_CAT1_TAB.
ENDLOOP.
SORT L_ALV_CAT1_TAB BY COL_POS.
*Creating Dynamic Internal table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = L_ALV_CAT1_TAB
IMPORTING
EP_TABLE = L_REF.
Assigning the Dynamic field Catalog to field symbol.
ASSIGN L_REF->* TO <F_FS>.
CREATE DATA G_WA LIKE LINE OF <F_FS>.
ASSIGN G_WA->* TO <F_WA>.
DELETE ADJACENT DUPLICATES FROM <F_FS> COMPARING ALL FIELDS.
ENDFORM. " get_fieldcat
*& Form display_data
FORM GET_FINAL_DATA.
*variable declaration
DATA: L_TOTAL TYPE I, " Row wise total
L_FILL TYPE I, " Count
L_TOT TYPE I. " Grand total
*To get the TOTAL qunatity in the last line of out put.
LOOP AT G_ITAB6_TAB.
CLEAR WA_ITAB5.
WA_ITAB5-TKNUM = 'TOTAL'(004).
WA_ITAB5-ERDAT = SPACE.
MOVE-CORRESPONDING G_ITAB6_TAB TO WA_ITAB5 .
LOOP AT G_SCANDATA_COUNT_TAB WHERE VHILM = G_ITAB6_TAB-VHILM.
WA_ITAB5-COUNT = WA_ITAB5-COUNT + G_SCANDATA_COUNT_TAB-COUNT.
ENDLOOP.
APPEND WA_ITAB5 TO G_ITAB5_TAB.
CLEAR WA_ITAB5.
ENDLOOP.
DESCRIBE TABLE G_ITAB5_TAB LINES L_TOT.
*>>>>>>>>
****To get total qunatity of all TKNUM
LOOP AT G_TOTAL_TAB .
L_TOTAL = L_TOTAL + G_TOTAL_TAB-QUANTITY.
ENDLOOP.
*>>>>>>>>
*To assign ERDAT to g_itab5_tab
LOOP AT G_ITAB5_TAB INTO WA_ITAB5 .
READ TABLE G_VTTK_TAB INTO WA_VTTK WITH KEY TKNUM = WA_ITAB5-TKNUM.
IF SY-SUBRC = 0.
WA_ITAB5-ERDAT = WA_VTTK-ERDAT.
MODIFY G_ITAB5_TAB FROM WA_ITAB5 TRANSPORTING ERDAT.
ENDIF.
ENDLOOP.
*Assigning value in each field to respective Field symbols.
LOOP AT G_ITAB5_TAB ASSIGNING <F_FS2>.
CLEAR G_TOTAL_TAB-QUANTITY.
ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_FS2> TO <F_FS6>.
ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_WA> TO <F_FS7>.
<F_FS7> = <F_FS6>.
CONDENSE <F_FS2>-VHILM NO-GAPS.
ASSIGN COMPONENT 'VHILM' OF STRUCTURE <F_FS2> TO <F_FS3>.
ASSIGN COMPONENT 5 OF STRUCTURE <F_FS2> TO <F_FS4>.
MOVE <F_FS3> TO G_VAR1.
ASSIGN COMPONENT G_VAR1 OF STRUCTURE <F_WA> TO <F_FS5>.
<F_FS5> = <F_FS4>.
ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_FS2> TO <F_FS16>.
ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_WA> TO <F_FS15>.
WRITE <F_FS16> TO <F_FS15> .
Inorder not to display the date '00/00/000',
if there is no DATE .
IF ( <F_FS15> CP '00/*' )
OR ( <F_FS15> CP '00.*' )
OR ( <F_FS15> CP '00-*' ).
<F_FS15> = SPACE.
ELSEIF ( <F_FS15> CO ' / /' )
OR ( <F_FS15> CO ' . .' )
OR ( <F_FS15> CO ' - -' ) .
<F_FS15> = SPACE.
ENDIF.
READ TABLE G_TOTAL_TAB WITH KEY TKNUM = <F_FS6>.
IF SY-SUBRC = 0.
ASSIGN G_TOTAL_TAB-QUANTITY TO <F_FS12>.
ASSIGN COMPONENT 'COUNT' OF STRUCTURE <F_FS2> TO <F_FS12>.
ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
<F_FS13> = <F_FS13> + <F_FS12>.
L_TOTAL = L_TOTAL + <F_FS12>.
ENDIF.
L_FILL = L_FILL + 1.
IF L_FILL = L_TOT.
ASSIGN L_TOTAL TO <F_FS12>.
ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
<F_FS13> = <F_FS12>.
ENDIF.
AT END OF <F_FS2>-TKNUM.
APPEND <F_WA> TO <F_FS>.
CLEAR <F_WA>.
ENDAT.
ENDLOOP.
CLEAR: <F_FS6>,
<F_FS7>,
<F_WA>.
*Call the screen where Custom container is defined
CALL SCREEN 0100.
ENDFORM. " display_data
Regards
Kannaiah -
Dynamic ALV as per the periods on the selection screen
Hello Experts
I am new to dynamic ALV , Please help me to sought out my confusion.
I want to create a dynamic ALV , based on the period mentioned at selection screen.
for example I want to display the movement type ( sum of the quantity ) for materials for the full month.
I want the ALV output as below.
Material .........qty 01.04.2011..... qty 02.04.2011... qty 03.04.2011 ........ qty 30.04.2011
AB1........................... 30.................... 20............................. 50......................... 200
AB2.................................................... 50 ............................. 80 ..........................10
I create an internal table itab with there fields to selact the data
MATNR
date
qty
select MATNR
date
qty
into itab
from mseg
where based on the selection screen.
then collect the data to other table date wise , now i have summrise data of material quantity
now the results after collection data into table itab2 is as follows
Material ................... date ................................ qty
AB1 .................... 01.04.2011....................... 30
AB1 ................... 02.04.2011 ....................... 20
AB1 ................... 03.04.2011....................... 50
AB1 ................... .30.04.2011....................... 200
AB2 .................... 02.04.2011....................... 50
AB2 ....................... 03.04.2011....................... 80
AB2 ....................... 30.04.2011 ....................... 10
How can I display these fields horizontally instead of vertically ,
and to the exact column as per the field catalog column header belongs to date.
it would be so helpful if somebody explain with code by taking the above example.
Thanks in AdvanceHello Both Experts ,
I write the below code and it is working for the requirement.
Can you please check
REPORT z_test_dynamic .
TABLES : mkpf , mseg .
TYPES : BEGIN OF t_mseg ,
mblnr TYPE mblnr ,
bwart TYPE bwart ,
matnr TYPE matnr ,
werks TYPE werks_d ,
menge TYPE menge_d ,
budat TYPE budat ,
END OF t_mseg.
TYPES : BEGIN OF t_mseg_1 ,
matnr TYPE matnr ,
menge TYPE menge_d ,
budat TYPE budat ,
END OF t_mseg_1.
DATA : gt_mseg TYPE STANDARD TABLE OF t_mseg ,
gs_mseg TYPE t_mseg,
gt_mseg_1 TYPE STANDARD TABLE OF t_mseg_1 ,
gs_mseg_1 TYPE t_mseg_1,
gt_mseg_2 TYPE STANDARD TABLE OF t_mseg_1 ,
gs_mseg_2 TYPE t_mseg_1..
DATA : gt_date TYPE STANDARD TABLE OF sy-datum ,
gs_date TYPE sy-datum..
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'CONTAINER_01',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_fieldcat TYPE lvc_t_fcat.
DATA: gp_table TYPE REF TO data.
FIELD-SYMBOLS: <gt_table> TYPE table.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_matnr FOR mseg-matnr ,
s_bwart FOR mseg-bwart NO INTERVALS,
s_werks FOR mseg-werks ,
s_budat FOR mkpf-budat .
PARAMETERS : p_mjahr TYPE mjahr OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
PERFORM field_catalog.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcat
IMPORTING
ep_table = gp_table.
ASSIGN gp_table->* TO <gt_table>.
PERFORM select_main_data.
PERFORM move_data.
*& Form select_main_data
* text
* --> p1 text
* <-- p2 text
FORM select_main_data .
SELECT mseg~mblnr
mseg~bwart
mseg~matnr
mseg~werks
mseg~menge
mkpf~budat
INTO TABLE gt_mseg
FROM mseg AS mseg INNER JOIN mkpf AS mkpf
ON mseg~mblnr = mkpf~mblnr AND
mseg~mjahr = mkpf~mjahr
WHERE matnr IN s_matnr AND
budat IN s_budat AND
werks IN s_werks AND
bwart IN s_bwart AND
mseg~mjahr EQ p_mjahr .
IF gt_mseg IS NOT INITIAL.
LOOP AT gt_mseg INTO gs_mseg.
gs_mseg_1-matnr = gs_mseg-matnr.
gs_mseg_1-budat = gs_mseg-budat.
gs_mseg_1-menge = gs_mseg-menge.
COLLECT gs_mseg_1 INTO gt_mseg_1.
ENDLOOP.
ENDIF.
gt_mseg_2 = gt_mseg_1.
DELETE ADJACENT DUPLICATES FROM gt_mseg_2 COMPARING matnr.
ENDFORM. " select_main_data
*& Form field_catalog
* text
* --> p1 text
* <-- p2 text
FORM field_catalog .
DATA : lt_day_attributes TYPE STANDARD TABLE OF casdayattr ,
ls_day_attributes TYPE casdayattr .
DATA: ls_fieldcat TYPE lvc_s_fcat ,
lv_fieldname TYPE lvc_fname.
IF s_budat-high IS INITIAL.
s_budat-high = s_budat-low.
ENDIF.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
* FACTORY_CALENDAR = ' '
* HOLIDAY_CALENDAR = ' '
date_from = s_budat-low
date_to = s_budat-high
language = sy-langu
* IMPORTING
* YEAR_OF_VALID_FROM =
* YEAR_OF_VALID_TO =
* RETURNCODE =
TABLES
day_attributes = lt_day_attributes
* EXCEPTIONS
* FACTORY_CALENDAR_NOT_FOUND = 1
* HOLIDAY_CALENDAR_NOT_FOUND = 2
* DATE_HAS_INVALID_FORMAT = 3
* DATE_INCONSISTENCY = 4
* OTHERS = 5
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT lt_day_attributes INTO ls_day_attributes.
gs_date = ls_day_attributes-date.
APPEND gs_date TO gt_date.
ENDLOOP.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-inttype = 'CHAR18'.
ls_fieldcat-coltext = 'MATERIAL'.
* ls_fieldcat-decimals_o = '2'.
ls_fieldcat-outputlen = 18.
APPEND ls_fieldcat TO gt_fieldcat.
LOOP AT gt_date INTO gs_date.
CONCATENATE 'QTY_' gs_date INTO lv_fieldname.
ls_fieldcat-fieldname = lv_fieldname.
ls_fieldcat-inttype = 'QUAN'.
ls_fieldcat-coltext = gs_date.
ls_fieldcat-decimals_o = '2'.
* ls_fieldcat-outputlen = 18.
APPEND ls_fieldcat TO gt_fieldcat.
ENDLOOP.
ENDFORM. " field_catalog
*& Form move_data
* text
* --> p1 text
* <-- p2 text
FORM move_data .
DATA: l_row TYPE sy-index.
FIELD-SYMBOLS: <ls_table>.
FIELD-SYMBOLS: <l_field> ,
<l_mseg_1> TYPE t_mseg_1.
DATA: ls_fieldcat TYPE lvc_s_fcat .
ASSIGN LOCAL COPY OF INITIAL LINE OF <gt_table> TO <ls_table>.
SORT gt_mseg_1 BY matnr.
LOOP AT gt_mseg_1 ASSIGNING <l_mseg_1> .
IF <l_field> IS ASSIGNED.
UNASSIGN <l_field>.
ENDIF.
MOVE-CORRESPONDING <l_mseg_1> TO <ls_table>.
READ TABLE gt_fieldcat INTO ls_fieldcat WITH KEY coltext = <l_mseg_1>-budat.
IF sy-subrc EQ 0.
ASSIGN COMPONENT ls_fieldcat-fieldname OF STRUCTURE <ls_table> TO <l_field>.
<l_field> = <l_mseg_1>-menge.
ELSE.
<l_field> = 0.
ENDIF.
AT end of matnr.
APPEND <ls_table> TO <gt_table>.
clear <ls_table>.
ENDAT.
ENDLOOP.
ENDFORM. " move_data
your answers help me lot . I am awarding the points.
Very Very Thanks
Edited by: Dilraj Singh on Apr 13, 2011 3:58 PM
Edited by: Dilraj Singh on Apr 13, 2011 4:09 PM
Edited by: Dilraj Singh on Apr 13, 2011 4:23 PM -
I am getting the following short dump error : Program " " not found".The fieldcat is successfully built but when Iam trying to call the method "create_dynamic_table" it is showing the error.
I executed the following Dynamic ALV program without any error yesterday,I did slight modifications and it is started showing the error.See the below code :
Data : t_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
FIELD-SYMBOLS : <it_dyn> TYPE STANDARD TABLE,
<wa_dyn>.
DATA : g_tdref TYPE REF TO data,
g_wdref TYPE REF TO data,
dats like vbbe-mbdat.
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mbdat FOR dats.
SELECTION-SCREEN : END OF BLOCK blk1.
wa_fieldcat-tabname = 'MSKA'.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'MSKA'.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-seltext = 'Material Number'.
wa_fieldcat-intlen = '18'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'MAKT'.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = 'MBDAT'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
DATA : d TYPE i,
v(02) TYPE n VALUE '0',
day(8) TYPE c.
d = s_mbdat-high - s_mbdat-low.
DO d TIMES.
v = v + 1.
CONCATENATE 'x Day' v INTO day.
wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = day.
wa_fieldcat-datatype = 'DATS'.
wa_fieldcat-seltext = day.
wa_fieldcat-intlen = '8'.
APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.
ENDDO.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = g_tdref.
ASSIGN g_tdref->* TO <it_dyn>.
CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
ASSIGN g_wdref->* TO <wa_dyn>.
What might be the problem?well...i executed exactly the same code as yours....and i got a table G_TDREF with four fields WERKS MATNR MAKTX and MBDAT successfully....
I even debugged the create_dynamic_table method and found that LVC_TABLE_CREATE function module has the i_callback_program as an optional parameter...so it should not be a problem....
could you please debug the create_dynamic_table method a bit to know exactly at what point the dump is occuring...
looks to be a system issue to me.....check if everything is correct in the system....it works perfectly fine for me -
How to make cell coloring in dynamic ALV,I did it in normal internal tables.Any body can help me here?
Or can anybody tell me how to convert a field symbol to an internal table? as I have created a dynamic IT.
Thanks in advance.Thanks for u r quick replies,Now Iam not getting any error,the program getting executed without any error.But Iam not getting any colors,what might be the problem? Do I need to pass IS_layot to ALV_GRID FM ? I have not created any Layout though,here is my complete code :
TABLES : vbbe.
TYPE-POOLS : slis.
*& Data Declarations *
DATA : diff TYPE i VALUE 0,
maktx LIKE makt-maktx,
labst LIKE mard-labst.
DATA : BEGIN OF it_data OCCURS 0,
matnr LIKE vbbe-matnr,
mbdat LIKE vbbe-mbdat,
omeng LIKE vbbe-omeng,
END OF it_data,
wa_data LIKE LINE OF it_data.
DATA : g_tdref TYPE REF TO data,
g_wdref TYPE REF TO data.
DATA : dats LIKE vbbe-mbdat,
lvc_t_fieldcat TYPE lvc_t_fcat,
lvc_s_fieldcat TYPE lvc_s_fcat,
it_fldcat TYPE slis_t_fieldcat_alv,
wa_fldcat TYPE slis_fieldcat_alv.
FIELD-SYMBOLS : <it_dyn> TYPE STANDARD TABLE,
<wa_dyn>,
<dyn_field>.
*& Selection-Screen *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mbdat FOR vbbe-mbdat OBLIGATORY.
PARAMETER p_werks LIKE mard-werks OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.
*& INITIALIZATION *
INITIALIZATION.
p_werks = '1200'.
*& Start-Of-Selection *
START-OF-SELECTION.
PERFORM f_build_lvc_and_slis.
PERFORM f_build_dynamic_it.
PERFORM f_get_data.
PERFORM f_get_fata_into_it.
PERFORM f_display_alv.
*& Form f_build_lvc
FORM f_build_lvc_and_slis.
*.................Build LVC Fieldcatalog...............................*
lvc_s_fieldcat-tabname = 'MSKA'.
lvc_s_fieldcat-col_pos = 1.
lvc_s_fieldcat-fieldname = 'WERKS'.
lvc_s_fieldcat-datatype = 'CHAR'.
lvc_s_fieldcat-intlen = '10'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tabname = 'MSKA'.
lvc_s_fieldcat-col_pos = 2.
lvc_s_fieldcat-fieldname = 'MATNR'.
lvc_s_fieldcat-datatype = 'CHAR'.
lvc_s_fieldcat-intlen = '18'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tabname = 'MAKT'.
lvc_s_fieldcat-col_pos = 3.
lvc_s_fieldcat-fieldname = 'MAKTX'.
lvc_s_fieldcat-datatype = 'CHAR'.
lvc_s_fieldcat-intlen = '10'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tabname = 'MARD'.
lvc_s_fieldcat-col_pos = 4.
lvc_s_fieldcat-fieldname = 'LABST'.
lvc_s_fieldcat-datatype = 'QUAN'.
lvc_s_fieldcat-intlen = '13'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tech = 'X'.
lvc_s_fieldcat-col_pos = 5.
lvc_s_fieldcat-fieldname = 'TCOLOR'.
lvc_s_fieldcat-ref_field = 'COLOR'.
lvc_s_fieldcat-ref_table = 'ZLVC_COL'.
lvc_s_fieldcat-scrtext_l = 'COLOR'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
*.................Build SLIS Fieldcatalog..............................*
wa_fldcat-tabname = 'MSKA'.
wa_fldcat-col_pos = 1.
wa_fldcat-fieldname = 'WERKS'.
wa_fldcat-datatype = 'CHAR'.
wa_fldcat-seltext_m = wa_fldcat-seltext_l = wa_fldcat-seltext_s =
'Plant'.
wa_fldcat-intlen = '6'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tabname = 'MSKA'.
wa_fldcat-outputlen = 15.
wa_fldcat-col_pos = 2.
wa_fldcat-fieldname = 'MATNR'.
wa_fldcat-datatype = 'CHAR'.
wa_fldcat-seltext_l = 'Material Number'.
wa_fldcat-intlen = '16'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tabname = 'MAKT'.
wa_fldcat-outputlen = 23.
wa_fldcat-col_pos = 3.
wa_fldcat-fieldname = 'MAKTX'.
wa_fldcat-datatype = 'CHAR'.
wa_fldcat-seltext_l = 'Material Description'.
wa_fldcat-intlen = '20'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tabname = 'MARD'.
wa_fldcat-col_pos = 4.
wa_fldcat-fieldname = 'LABST'.
wa_fldcat-datatype = 'QUAN'.
wa_fldcat-intlen = '13'.
wa_fldcat-seltext_m = wa_fldcat-seltext_l = wa_fldcat-seltext_s =
'x Stock'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tech = 'X'.
wa_fldcat-col_pos = 5.
wa_fldcat-fieldname = 'TCOLOR'.
wa_fldcat-ref_fieldname = 'COLOR'.
wa_fldcat-ref_tabname = 'ZLVC_COL'.
wa_fldcat-seltext_l = 'COLOR'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
*.................Build Dynamic Fields for LVC and SLIS................*
DATA : d TYPE i,
col(6) TYPE n VALUE '0',
date TYPE dats,
day(8) TYPE c,
number(2) TYPE n VALUE '0'.
d = s_mbdat-high - s_mbdat-low + 1.
date = s_mbdat-low - 1.
DO d TIMES.
number = number + 1.
date = date + 1.
col = col + 1.
CONCATENATE 'x Day' number INTO day.
lvc_s_fieldcat-tabname = 'VBBE'.
lvc_s_fieldcat-col_pos = col + 5.
lvc_s_fieldcat-fieldname = date.
lvc_s_fieldcat-datatype = 'QUAN'.
lvc_s_fieldcat-intlen = '15'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
wa_fldcat-tabname = 'VBBE'.
wa_fldcat-col_pos = col + 5.
wa_fldcat-fieldname = date.
wa_fldcat-datatype = 'QUAN'.
wa_fldcat-intlen = '15'.
wa_fldcat-seltext_l = day.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
ENDDO.
ENDFORM. " f_build_lvc
*& Form f_build_dynamic_it
FORM f_build_dynamic_it .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lvc_t_fieldcat
IMPORTING
ep_table = g_tdref.
ASSIGN g_tdref->* TO <it_dyn>.
CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
ASSIGN g_wdref->* TO <wa_dyn>.
ENDFORM. " f_build_dynamic_it
*& Form f_get_data
FORM f_get_data .
SELECT matnr mbdat omeng FROM vbbe INTO CORRESPONDING FIELDS OF TABLE
it_data WHERE mbdat IN s_mbdat AND
werks = p_werks.
DELETE it_data WHERE omeng = 0 .
SORT it_data BY matnr ASCENDING.
ENDFORM. " f_get_data
*& Form f_get_fata_into_it
FORM f_get_fata_into_it .
FIELD-SYMBOLS : <fs>,
<ta_color> TYPE table.
DATA : field(15) TYPE c,
col TYPE lvc_s_scol.
LOOP AT it_data INTO wa_data.
SELECT SINGLE maktx FROM makt INTO maktx WHERE matnr =
wa_data-matnr.
SELECT SINGLE labst FROM mard INTO labst WHERE matnr =
wa_data-matnr AND werks = p_werks.
diff = wa_data-mbdat - s_mbdat-low + 6.
ASSIGN COMPONENT 1 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = p_werks.
ASSIGN COMPONENT 2 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = wa_data-matnr.
ASSIGN COMPONENT 3 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = maktx.
ASSIGN COMPONENT 4 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = labst.
ASSIGN COMPONENT diff OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = wa_data-omeng.
IF labst < wa_data-omeng.
col-fname = wa_data-mbdat.
col-color-col = '5' .
col-color-int = '1'.
ELSE.
col-fname = wa_data-mbdat.
col-color-col = '5' .
col-color-int = '0' .
ENDIF.
ASSIGN COMPONENT 'TCOLOR' OF STRUCTURE <wa_dyn> TO <ta_color>.
APPEND col TO <ta_color> .
APPEND <wa_dyn> TO <it_dyn>.
CLEAR <wa_dyn>.
ENDLOOP.
ENDFORM. " f_get_fata_into_it
*& Form f_display_alv
FORM f_display_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = it_fldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = <it_dyn>
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " f_display_alv -
ALV Title Not Display after transporting the Programme from DeV to Qlty
Hellow Experts,
i developed one ALV report with two screens, i transported the report from Development server to Qulaity server.
in Development server report are working fine but in Qulaity server after transporting the TiTle of ALV not display , plz give me some hint , below is my code to display alv title
DATA: alv_grid TYPE REF TO cl_gui_alv_grid.
DATA:alv_grid_ref type ref to CL_GUI_ALV_GRID.
DATA: layout TYPE lvc_s_layo.
layout-grid_title = 'Daily Material Reports.' .
DATA: fieldcat TYPE lvc_t_fcat.
I m using ALL METHOD alv_grid->set_table_for_first_display method for display alv .
Thanks,
Regards
Neha.Hi neha,
use the sap/help link to solve your issue,
[http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b5533cd30911d2b467006094192fe3/content.htm]
if not use the below example code ,
Heading 3 :h3 Set the title of the grid
Fill the grid_title field of structure lvc_s_layo.
Note that the structure lvc_s_layo can be used for to customize the grid appearance in many ways.
DATA:
ALV control: Layout structure
gs_layout TYPE lvc_s_layo.
For example :
Set grid title
gs_layout-grid_title = 'Flights'.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
is_layout =gs_layout*
CHANGING
it_outtab = gi_sflight.
Regards,
Saravana.S
Edited by: saravanasap on Dec 21, 2011 8:13 AM -
Dynamic ALV and cl_abap_structdescr Create method
Hi
In the process of creation of Dynamic ALV, as I have char_name and char_descr fields, I have to use char_descr as column header of ALV because char_name which has entries something like DVS_******(that do not make any sense to user). I am facing 2 problems here using the scenario above.
1. char_descr contains characters like '[', ']', ' /', '.', space which are invalid characters for method cl_abap_structdescr=>create(). How to handle scenario like this?
2. assign (lv_value) to <value>.
if sy-subrc = 0.
<value> = ls_bapi_char_value-charvalue.
if <value> is assigned.
move ls_bapi_char_value-charvalue to <value>.
where-> concatenate '<table_dyn_wa>-' ls_bapi_char-char_descr into lv_value
<value> type any
<table_dyn_wa>- is dynamic table with structure created with cl_abap_tabledescr=>create( p_line_type = stru_type )
with above code for few fields data is being assigned and for few sy-subrc = 4. The table from where I am reading the field contains char_name associated with it and not char_descr. For the fields whose char_name and char_descr matches exactly, ALV displays data for it.
How to resolve the issue so that I could get all the data?
Let me know if further details are needed.
Thanks, in advance
Trupti
Edited by: TRUPTI KALLURWAR on Jul 9, 2010 7:08 PMHello Srikanth,
CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE( ) uses the GENERATE SUBROUTINE POOL technique to create the dynamic internal tables.
And as per the SAP documentation,
In an internal mode, a maximum of 36 temporary subroutine pools may be created.
Source: [http://help.sap.com/abapdocu_702/en/abapgenerate_subroutine_pool.htm]
Btw why are you crating 36 dynamic internal table? That's way too far-fetched even for the RTTC classes
BR,
Suhas -
Problem in Dynamic ALV - inserting values in proper field of a table.
Hi gurus,
As per the user requirement I need to create a dynamic alv report. The fields will be display according to the period entered.
I have already build the alv and it is working fine. But My questio is how can I append data into internal table in its proper field.
suppose I have enter period 1 to 3 in selection screen. Then my table structure will be
JAN | FEB | MAR
Upto this is is working fine, fields are generated dynamically , but how can I insert data only in perticular field.
like
itab-JAN = 001.
itab-FEB = 002.
itab-MAR = 003.
append itab
JAN | FEB | MAR
001 002 003
Please give me a solution of that. waiting for reply.hI,
loop at <dyn_table> assigning <wa>.
lv_count = 001.
*perform get_short_tet of month in a varibale say lv_var
assign component LV_VAR of structure <wa> to <dyn_field1>.
<dyn_field1> = lv_count.
lv_count = lv_count + 1.
endloop.
Regards,
mrunal
Edited by: Mrunal Shyamkant Patki on Nov 5, 2009 10:53 AM
Edited by: Mrunal Shyamkant Patki on Nov 5, 2009 10:54 AM -
Problem in print out of Dynamic ALV
Hi ,
I am using dynamic ALV to address a requirement. The ALV is working fine and the output is also coming corretly, even in spool.
But if the width of dynamic table exceeds a limit, then nothing is coming in the print out.
If anyone has faced similar problem or knows how to tackle this problem, please advise what can be done here.
Thanks,
SonalHi,
Can you try to increase field with to maximun as per your requirement.
Regards,
Sai -
How to display dynamic header title in the report?
I have a req to display dynamic header title in the report.
When a id is entered in the prompt text, it will display the user data based on that user_id.
so similarly....the header title should vary each time when you select different user_id.
How can we implement this?>
Zack H wrote:
> Lazaro,
>
> It depends on what you want displayed in the heading for each id.
> Please elaborate.
>
> Thanks,
> Zack H.
Zack..I have several projects listed under several project id's...
so when a user selects project id 00164 then it should display something like "Project document for Jon Doe"
again when the user selects project id as 00192 then it should display something like "project document for Zimmerman"
Did you get it?? -
Hi all
i try to put color in the dynamic alv, but i become a dump message
Runtime Errors OBJECTS_MOVE_NOT_SUPPORTED
Date and Time 28.10.2010 08:46:49
Short text
Conversion of type "h" to type "g" not supported.
What happened?
Error in the ABAP Application Program
The current ABAP program "SAPLSLVC" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
You attempted to move one data object to another.
This is not possible here because the conversion of a data object
of type "h" to type "g" is not supported.
my code implementation looks like
method validate_order_deli.
data ls_scol type lvc_s_scol.
data ls_colo type lvc_s_colo.
data ls_aoc_percent type zsd_aoc_percent.
data lf_deliv type lifmg.
data lf_db_percent type f.
data lf_calc_perc type f.
refresh et_color.
select single *
from zsd_aoc_percent
into corresponding fields of ls_aoc_percent
where acin = 'X'.
if sy-subrc <> 0.
exit.
endif.
lf_db_percent = ls_aoc_percent-percent.
* ls_scol-fname = if_fieldname.
ls_scol-fname = 'MATNR'.
if if_deliv <> 0.
me->calc_amour_unit(
exporting
if_matnr = if_matnr
if_amount = if_deliv
if_input = if_deliv_unit
if_output = if_order_unit
importing
ef_amount = lf_deliv
lf_calc_perc = ( lf_deliv * 100 ) / if_order.
if lf_calc_perc < lf_db_percent.
ls_colo-col = cl_gui_resources=>list_col_positive.
else.
ls_colo-col = cl_gui_resources=>list_col_negative.
endif.
ls_scol-color = ls_colo.
append ls_scol to et_color.
else.
exit.
endif.
endmethod. "validate_order_deli
method add_color_field.
data ls_fcat type lvc_s_fcat.
ls_fcat-fieldname = 'COLOR'.
ls_fcat-ref_field = 'COLTAB'.
ls_fcat-ref_table = 'CALENDAR_TYPE'.
append ls_fcat to ct_fcat.
endmethod. "add_color_field
ls_lvc_s_layo-cwidth_opt = 'X'.
ls_lvc_s_layo-ctab_fname = 'COLOR'.
i don't no, what's wrong...
thx for help*& Form generate_alv
* text
form generate_alv.
field-symbols <lt_any_table> type any table.
if lrf_gui_custom_container is initial.
create object lrf_gui_custom_container
exporting
container_name = lf_container.
create object lrf_gui_alvgrid
exporting
i_parent = lrf_gui_custom_container.
ls_lvc_s_layo-cwidth_opt = 'X'.
ls_lvc_s_layo-ctab_fname = 'COLOR'.
check sy-subrc = 0.
call method lrf_gui_alvgrid->set_table_for_first_display
exporting
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name = 'ZAM_CELL_COLOR'
* is_variant = ls_disvariant
* i_save = 'A'
* i_default = 'X'
is_layout = ls_lvc_s_layo
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
changing
it_outtab = <gt_table>
it_fieldcatalog = gt_dyn_fcat
* it_filter =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
endform. "generate_alv
*& Module STATUS_0100 OUTPUT
* text
module status_0100 output.
set pf-status 'ZAM_CELL_STATUS'.
set titlebar 'ZAM_CELL_TIT'.
perform generate_alv.
endmodule. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
module user_command_0100 input.
data lf_okcode type syucomm.
call method cl_gui_cfw=>dispatch.
lf_okcode = ok_code.
case lf_okcode.
when 'EXIT'.
set screen 0.
leave screen.
when 'CANCEL'.
leave program.
when 'BACK'.
set screen 0.
leave screen..
endcase.
endmodule. " USER_COMMAND_0100 INPUT -
Hi,
Please tell how to perform Subtotal in dynamic ALV Report.
Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
Thanks.Hi,
Please tell how to perform Subtotal in dynamic ALV Report.
Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
Thanks.
Maybe you are looking for
-
Dear all, I am getting an error "Invalid Payment Name" in outgoing payment window in sap b1 2005b. Kindly help on the issue.
-
What are the possible ways of importing VPF data into Oracle Spatial? Jacek Skowronek
-
Installing X11 on Mac Pro with 10.4.8
I just got my Mac Pro and tried to install X11 1.1.2 from the mac site. However I get an error message saying that it cannot be installed on my drive because new software is already installed. However my system is brand new with no X11 installed. Tha
-
In xk01 transaction if the data along with the bank details has to be updates how would be the flat file like, Will there be two different files or entire data put in one file. Show me the structure of it...... regards johny
-
I attempted to compare two strings whether they are equal or not. They should return true if both are equal. One string is based on Taxonomy's Term (i.e. Term.Name) whereas other string is based on String object. The problem is that both strings whic