Skip to Content
author's profile photo Former Member
Former Member

partially automated field catalog

Hi friends,

i know about fully automated field catalog using fm REUSE_ALV_FIELDCATALOG_MERGE and i know about building field catlog manually , but can any one explain me about partially automated field catalog with sample program.

points will be given

Regards

Vijaya

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 11:49 AM

    Hi vijaya,

    see the link below for creation of field catalog without using fm REUSE_ALV_FIELDCATALOG_MERGE

    http://www.sap-img.com/abap/sample-alv-heading-in-alv.htm

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2008 at 11:51 AM

    hi

    good

    check this report

    &----


    *& Include ZJNCINCLUDE

    *

    &----


    &----


    *& Reincarnations of REUSE_ALV_FIELDCATALOG_MERGE

    &----


    *----


    • These FORMs are for people accustomed to

    • REUSE_ALV_FIELDCATALOG_MERGE (despite the 72 ch source line limit)

    • but not happy with LVC_FIELDCATALOG_MERGE

    • We do not want to crowd DDIC with too many structures!

    *----


    &----


    *& Form ZJNC_DUMP_LIST Our Good Old ALV list - RECOMMENDED!

    &----


    FORM zjnc_dump_list USING value(p_it_name) TYPE c

    value(p_wa_name) TYPE c

    value(p_heading) TYPE c.

    TYPE-POOLS: slis.

    DATA:

    stru_ref TYPE REF TO cl_abap_structdescr,

    comp_tab TYPE abap_compdescr_tab,

    one_comp TYPE abap_compdescr,

    one_name TYPE string,

    type_ref TYPE REF TO cl_abap_typedescr,

    is_ddic TYPE abap_bool,

    lt_ddic TYPE dd_x031l_table,

    wa_ddic TYPE x031l,

    lt_fcat TYPE slis_t_fieldcat_alv,

    wa_fcat TYPE slis_fieldcat_alv,

    ls_layo TYPE slis_layout_alv,

    l_alv TYPE REF TO cl_gui_alv_grid.

    FIELD-SYMBOLS: <fs_type> TYPE ANY,

    <fs_table> TYPE STANDARD TABLE,

    <fs_line> TYPE ANY.

    ASSIGN (p_it_name) TO <fs_table>.

    ASSIGN (p_wa_name) TO <fs_line>.

    ls_layo-colwidth_optimize = 'X'.

    ls_layo-zebra = 'X'.

    ls_layo-window_titlebar = p_heading.

    ls_layo-box_tabname = p_it_name.

    stru_ref ?= cl_abap_structdescr=>describe_by_data( <fs_line> ).

    comp_tab = stru_ref->components.

    LOOP AT comp_tab INTO one_comp.

    CLEAR wa_fcat.

    wa_fcat-tabname = p_it_name.

    wa_fcat-fieldname = one_comp-name.

    CONCATENATE p_wa_name '-' one_comp-name INTO one_name.

    ASSIGN (one_name) TO <fs_type>.

    type_ref ?= cl_abap_typedescr=>describe_by_data( <fs_type> ).

    is_ddic = type_ref->is_ddic_type( ).

    IF is_ddic = abap_true.

    lt_ddic = type_ref->get_ddic_object( ).

    LOOP AT lt_ddic INTO wa_ddic.

    CLEAR wa_ddic-tabname.

    SELECT SINGLE

    dd03l~tabname

    INTO wa_ddic-tabname

    FROM dd03l

    WHERE dd03l~fieldname = wa_ddic-fieldname

    AND dd03l~tabname NOT LIKE '/%'. " I live in normal

    namespace

    wa_fcat-ref_tabname = wa_ddic-tabname.

    wa_fcat-ref_fieldname = wa_ddic-fieldname.

    SELECT SINGLE

    dd04t~scrtext_s

    dd04t~scrtext_m

    dd04t~scrtext_l

    INTO (wa_fcat-seltext_s, wa_fcat-seltext_m,

    wa_fcat-seltext_l)

    FROM dd04t

    WHERE dd04t~rollname = wa_ddic-fieldname

    AND dd04t~ddlanguage = sy-langu.

    ENDLOOP.

    ELSE.

    MOVE one_comp-name TO: wa_fcat-seltext_s, wa_fcat-seltext_m,

    wa_fcat-seltext_l.

    ENDIF.

    APPEND wa_fcat TO lt_fcat.

    ENDLOOP.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    is_layout = ls_layo

    it_fieldcat = lt_fcat

    TABLES

    t_outtab = <fs_table>.

    ENDFORM. "ZJNC_DUMP_LIST

    &----


    *& Form ZJNC_DUMP_GRID Object Oriented

    &----


    FORM zjnc_dump_grid USING value(p_it_name) TYPE c

    value(p_wa_name) TYPE c

    value(p_screen) TYPE n

    value(p_heading) TYPE c.

    DATA:

    stru_ref TYPE REF TO cl_abap_structdescr,

    comp_tab TYPE abap_compdescr_tab,

    one_comp TYPE abap_compdescr,

    one_name TYPE string,

    type_ref TYPE REF TO cl_abap_typedescr,

    is_ddic TYPE abap_bool,

    lt_ddic TYPE dd_x031l_table,

    wa_ddic TYPE x031l,

    lt_fcat TYPE lvc_t_fcat,

    wa_fcat TYPE lvc_s_fcat,

    ls_layo TYPE lvc_s_layo,

    l_alv TYPE REF TO cl_gui_alv_grid.

    FIELD-SYMBOLS: <fs_type> TYPE ANY,

    <fs_table> TYPE ANY TABLE,

    <fs_line> TYPE ANY.

    ASSIGN (p_it_name) TO <fs_table>.

    ASSIGN (p_wa_name) TO <fs_line>.

    ls_layo-cwidth_opt = 'X'.

    ls_layo-zebra = 'X'.

    ls_layo-grid_title = p_heading.

    ls_layo-box_fname = p_it_name.

    stru_ref ?= cl_abap_structdescr=>describe_by_data( <fs_line> ).

    comp_tab = stru_ref->components.

    LOOP AT comp_tab INTO one_comp.

    CLEAR wa_fcat.

    wa_fcat-tabname = p_it_name.

    wa_fcat-fieldname = one_comp-name.

    CONCATENATE p_wa_name '-' one_comp-name INTO one_name.

    ASSIGN (one_name) TO <fs_type>.

    type_ref ?= cl_abap_typedescr=>describe_by_data( <fs_type> ).

    is_ddic = type_ref->is_ddic_type( ).

    IF is_ddic = abap_true.

    lt_ddic = type_ref->get_ddic_object( ).

    LOOP AT lt_ddic INTO wa_ddic.

    CLEAR wa_ddic-tabname.

    SELECT SINGLE

    dd03l~tabname

    INTO wa_ddic-tabname

    FROM dd03l

    WHERE dd03l~fieldname = wa_ddic-fieldname

    AND dd03l~tabname NOT LIKE '/%'. " I live in normal

    namespace

    wa_fcat-ref_table = wa_ddic-tabname.

    wa_fcat-ref_field = wa_ddic-fieldname.

    SELECT SINGLE

    dd04t~scrtext_s

    dd04t~scrtext_m

    dd04t~scrtext_l

    INTO (wa_fcat-scrtext_s, wa_fcat-scrtext_m,

    wa_fcat-scrtext_l)

    FROM dd04t

    WHERE dd04t~rollname = wa_ddic-fieldname

    AND dd04t~ddlanguage = sy-langu.

    ENDLOOP.

    ELSE.

    MOVE one_comp-name TO: wa_fcat-scrtext_s, wa_fcat-scrtext_m,

    wa_fcat-scrtext_l.

    ENDIF.

    APPEND wa_fcat TO lt_fcat.

    ENDLOOP.

    CREATE OBJECT l_alv EXPORTING i_parent = cl_gui_container=>screen0.

    CALL METHOD l_alv->set_table_for_first_display

    EXPORTING

    is_layout = ls_layo

    CHANGING

    it_outtab = <fs_table>

    it_fieldcatalog = lt_fcat.

    CALL SELECTION-SCREEN p_screen.

    ENDFORM. "ZJNC_DUMP_GRID

    -


    • SAMPLE TEST PROGRAM

    REPORT yjnc1.

    INCLUDE zjncinclude.

    TYPES : BEGIN OF ty_pur,

    ebeln1 TYPE ekko-ebeln,

    aedat TYPE ekko-aedat,

    ebelp TYPE ekpo-ebelp,

    matnr TYPE ekpo-matnr,

    txz01 TYPE ekpo-txz01,

    menge1 TYPE ekpo-menge,

    belnr1 TYPE ekbe-belnr,

    budat1 TYPE ekbe-budat,

    bwart TYPE ekbe-bwart,

    menge2 TYPE ekbe-menge,

    belnr2 TYPE ekbz-belnr,

    budat2 TYPE ekbz-budat,

    menge3 TYPE ekbz-menge,

    dmbtr TYPE ekbz-dmbtr,

    buzei TYPE ekbz-buzei,

    jnc1 TYPE sy-datum,

    jnc2 TYPE i,

    jnc3(4) TYPE c,

    END OF ty_pur.

    DATA: it_pur TYPE STANDARD TABLE OF ty_pur,

    wa_pur TYPE ty_pur,

    rows TYPE i.

    • Not Recommended Style but still used!

    DATA: BEGIN OF it_mat OCCURS 0,

    jnc1 TYPE sy-datum,

    matnr LIKE makt-matnr,

    jnc2 TYPE i,

    maktx LIKE makt-maktx,

    mtart TYPE mara-mtart,

    jnc3(4) TYPE c,

    END OF it_mat.

    DATA: BEGIN OF it_str OCCURS 0.

    INCLUDE STRUCTURE makt.

    DATA: END OF it_str.

    SELECTION-SCREEN BEGIN OF SCREEN 1001.

    SELECTION-SCREEN END OF SCREEN 1001.

    START-OF-SELECTION.

    MOVE 100 TO rows.

    SELECT ekko~ebeln

    ekko~aedat

    ekpo~ebelp

    ekpo~matnr

    ekpo~txz01

    ekpo~menge

    ekbe~belnr

    ekbe~budat

    ekbe~bwart

    ekbe~menge

    ekbz~belnr

    ekbz~budat

    ekbz~menge

    ekbz~dmbtr

    ekbz~buzei

    INTO TABLE it_pur

    UP TO rows ROWS

    FROM ekko

    INNER JOIN ekpo

    ON ekkoebeln = ekpoebeln

    AND ekpo~loekz = ' '

    INNER JOIN ekbe

    ON ekpoebeln = ekbeebeln

    AND ekpoebelp = ekbeebelp

    AND ekbe~bewtp = 'E'

    LEFT OUTER JOIN ekbz

    ON ekpoebeln = ekbzebeln

    AND ekpoebelp = ekbzebelp

    AND ekbz~bewtp = 'M'

    WHERE ekko~bstyp = 'F'

    AND ekko~loekz = ' '

    ORDER BY ekko~ebeln

    ekpo~ebelp.

    LOOP AT it_pur INTO wa_pur.

    COMPUTE wa_pur-jnc1 = sy-datum - sy-tabix.

    MOVE sy-tabix TO wa_pur-jnc2.

    MOVE 'Helo' TO wa_pur-jnc3.

    MODIFY it_pur FROM wa_pur.

    ENDLOOP.

    • PERFORM zjnc_dump_grid USING 'IT_PUR' 'WA_PUR' 1001 'Purchase

    Report'.

    • IT_PUR is as per recommended OO style

    PERFORM zjnc_dump_list USING 'IT_PUR' 'WA_PUR' 'Purchase Dump'.

    SELECT makt~matnr

    makt~maktx

    mara~mtart

    INTO CORRESPONDING FIELDS OF TABLE it_mat

    UP TO rows ROWS

    FROM mara INNER JOIN makt

    ON maktmatnr = maramatnr

    AND makt~spras = sy-langu.

    LOOP AT it_mat.

    COMPUTE it_mat-jnc1 = sy-datum - sy-tabix.

    MOVE sy-tabix TO it_mat-jnc2.

    MOVE 'Helo' TO it_mat-jnc3.

    MODIFY it_mat.

    ENDLOOP.

    • PERFORM zjnc_dump_grid USING 'IT_MAT[]' 'IT_MAT' 1001 'Material

    Dump'.

    • Note that IT_MAT with Header line is 2 in 1

    • IT_MAT[] is the table object and IT_MAT is the header work area

    PERFORM zjnc_dump_list USING 'IT_MAT[]' 'IT_MAT' 'Material Dump'.

    SELECT *

    INTO TABLE it_str

    UP TO rows ROWS

    FROM makt

    WHERE makt~spras = sy-langu.

    • Note that IT_STR with Header line is 2 in 1

    • IT_STR[] is the table object and IT_STR is the header work area

    • As FORM zjnc_dump_list uses RTTI there is no special case for

    Structures

    PERFORM zjnc_dump_list USING 'IT_STR[]' 'IT_STR' 'Structure Dump'

    thanks

    mrutyun^

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.