2009 Feb 10 6:19 AM
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
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
2009 Feb 10 6:21 AM
Hi
Just use multiple SET TITLE commands with the diff titles based on your conditions.
Should suffice.
Cheers
Ravish
2009 Feb 10 7:02 AM
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
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |