Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Set the field catalog dynamically

Former Member
0 Likes
1,055

Hi!! I have to set an ALV report and I cannot solve the following problem: In my alv report I have to display data from several tables and views, one of the columns represent the total maintenance cost during a month. This data is stored in a database table PMCO,in which there're 12 fields representing maintenance costs, those fields' names are wrt01......wrt12(that is from january to dec). The user has to select the month and deppending on this month I have to set the field catalog.

I've already manage to read on the output table this cost dynamically but now I don't know how to set the fieldname dynamically.

I think it's possible using field symbols, but I have no idea about field symbols.

Just in case it helps this is the way I set the field catalog:

DATA: grid TYPE REF TO cl_gui_alv_grid,

g_custom_container TYPE REF TO cl_gui_custom_container,

gt_fieldcat TYPE LVC_T_FCAT WITH HEADER LINE.

TYPES: BEGIN OF st_output,

tplnr LIKE viaufkst-tplnr,

equnr LIKE viaufkst-equnr,

pltxt LIKE iflo-pltxt,

acpos LIKE pmco-acpos,

aufnr LIKE aufk-aufnr,

auart LIKE aufk-auart,

ktext LIKE aufk-ktext,

swerk LIKE viaufkst-swerk,

iwerk LIKE viaufkst-iwerk,

shtxt LIKE itob-shtxt,

objnr LIKE aufk-objnr,

wrttp LIKE pmco-wrttp,

coste_r LIKE pmco-wrt09,

coste_p LIKE pmco-wrt09,

END OF st_output.

DATA gt_output TYPE STANDARD TABLE OF st_output WITH HEADER LINE.

.............

For each field i have th following:

.......................................

gt_fieldcat-fieldname = 'ACPOS'.

gt_fieldcat-ref_table = 'PMCO'.

append gt_fieldcat.

Thanks to all!!

Hi!! I have to set an ALV report and I cannot solve the following problem: In my alv report I have to display data from several tables and views, one of the columns represent the total maintenance cost during a month. This data is stored in a database table PMCO,in which there're 12 fields representing maintenance costs, those fields' names are wrt01......wrt12(that is from january to dec). The user has to select the month and deppending on this month I have to set the field catalog.

I've already manage to read on the output table this cost dynamically but now I don't know how to set the fieldname dynamically.

I think it's possible using field symbols, but I have no idea about field symbols.

Just in case it helps this is the way I set the field catalog:

DATA: grid TYPE REF TO cl_gui_alv_grid,

g_custom_container TYPE REF TO cl_gui_custom_container,

gt_fieldcat TYPE LVC_T_FCAT WITH HEADER LINE.

TYPES: BEGIN OF st_output,

tplnr LIKE viaufkst-tplnr,

equnr LIKE viaufkst-equnr,

pltxt LIKE iflo-pltxt,

acpos LIKE pmco-acpos,

aufnr LIKE aufk-aufnr,

auart LIKE aufk-auart,

ktext LIKE aufk-ktext,

swerk LIKE viaufkst-swerk,

iwerk LIKE viaufkst-iwerk,

shtxt LIKE itob-shtxt,

objnr LIKE aufk-objnr,

wrttp LIKE pmco-wrttp,

coste_r LIKE pmco-wrt09,

coste_p LIKE pmco-wrt09,

END OF st_output.

DATA gt_output TYPE STANDARD TABLE OF st_output WITH HEADER LINE.

.............

For each field i have th following:

.......................................

gt_fieldcat-fieldname = 'ACPOS'.

gt_fieldcat-ref_table = 'PMCO'.

append gt_fieldcat.

Thanks to all!!

4 REPLIES 4
Read only

Former Member
0 Likes
845

Hi

U can use the fm LVC_FIELDCATALOG_MERGE to create the fieldcatalog, you only to transfer to it the name of the catalog needs for a certain month

Max

Read only

0 Likes
845

Refer the below link. It might help you

http://sap.niraj.tripod.com/id66.html

regards

Vivek

<b> reward points for all the useful answers </b>

Read only

Former Member
0 Likes
845

Hi,

See the below thread ..

Regards

Sudheer

Read only

Former Member
0 Likes
845

As to my understand of the problem, you wish to set the field title as Jan_Cost etc depending on the selected month...if that is the case you can do the below.

SELECT KTV into lcmon from t247

where spras = sy-langu and mnr = pmonth.

concatenate lcmon '_Cost' into lfieldtitle.

concatenate 'WRT' pmonth into lfield.

In your field catalog you can set the

SELTEXT_M = lfieldtitle.

FIELDNAME = lfield.

TABNAME = 'PMCO'.