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

alv variant problem

Hi,

I have got a requirement where i need to display the fields in ouutput based on the variant i choose/select at selection screen.. that means the fields should be varying based on the variant chosen at selection screen..

pls i need a good example .....plsss

Thanks in ADVANCE

Jay

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 12, 2007 at 07:05 AM

    Hi Jay,

    Check this code. Its all about using layout variants.

    Hope this helps.

    Reward if helpful,

    pritha.

    report zsales_order.

    type-pools: slis.

    *DATA DECLARATION.

    types: begin of i_vbak,

    vbeln type vbeln_va,

    augru type augru,

    end of i_vbak.

    types: begin of i_vbap,

    vbeln type vbeln_va,

    augru type augru,

    posnr type posnr_va,

    matnr type matnr,

    zmeng type dzmeng,

    end of i_vbap.

    types: begin of i_makt,

    matnr type matnr,

    maktx type maktx,

    end of i_makt.

    types: begin of i_lips,

    posnr type posnr_vl,

    matnr type matnr,

    lfimg type lfimg,

    end of i_lips.

    types: begin of i_reason,

    spras type spras,

    augru type augru,

    bezei type bezei40,

    end of i_reason.

    types: begin of i_vbpa,

    vbeln type vbeln,

    parvw type parvw,

    kunnr type kunnr,

    end of i_vbpa.

    types: begin of i_kna1,

    kunnr type kunnr,

    name1 type name1_gp,

    end of i_kna1.

    types: begin of i_final,

    vbeln type vbeln_va,

    posnr type posnr_va,

    matnr type matnr,

    zmeng type dzmeng,

    maktx type maktx,

    lfimg type lfimg,

    spras type spras,

    augru type augru,

    bezei type bezei40,

    parvw type parvw,

    kunnr type kunnr,

    name1 type name1_gp,

    end of i_final.

    *INTERNAL TABLES

    data: it_vbak type standard table of i_vbak.

    data: it_vbap type standard table of i_vbap.

    data: it_makt type standard table of i_makt.

    data: it_lips type standard table of i_lips.

    data: it_vbpa type standard table of i_vbpa.

    data: it_kna1 type standard table of i_kna1.

    data: it_final type standard table of i_final.

    data: it_reason type standard table of i_reason.

    data : v_flag.

    *WORK AREA

    data: wa_vbak type i_vbak.

    data: wa_vbap type i_vbap.

    data: wa_makt type i_makt.

    data: wa_lips type i_lips.

    data: wa_vbpa type i_vbpa.

    data: wa_kna1 type i_kna1.

    data: wa_final type i_final.

    data: wa_reason type i_reason.

    *DATA DECLARATION.

    data: v_progname type sy-repid.

    data: v_vbeln type vbak-vbeln.

    data: v_gridtitle type lvc_title.

    *PARAMETERS: D_VARI LIKE DISVARIANT-VARIANT.

    data: i_variant like disvariant.

    data: p_vari like disvariant-variant.

    *DATA DECLARATION FOR CATALOGS LAYOUT SORT EVENTCATALOG TOPOFPAGE.

    data: i_fieldcat type slis_t_fieldcat_alv.

    data: i_layout type slis_layout_alv.

    data: i_sortinfo type slis_t_sortinfo_alv.

    data: i_listheader type slis_t_listheader.

    data: i_eventcat type slis_t_event.

    *INITIALIZATION - First point of execution of program

    • To initialize Any variables that are to be

    • used in the program, even before selection screen

    • appears.

    initialization.

    v_progname = sy-repid.

    v_flag = space.

    perform z_default_variant.

    *SELECTION SCREEN

    selection-screen begin of block blk1 with frame title text-002.

    select-options: s_vbeln for v_vbeln.

    selection-screen end of block blk1.

    *Variable for ALV Variant

    selection-screen begin of block b_var with frame title text-020.

    parameters: d_vari like disvariant-variant.

    selection-screen end of block b_var.

    *AT SLECTION-SCREEN.

    at selection-screen.

    perform z_validations.

    *AT SELECTION SCREEN.

    at selection-screen on d_vari.

    • CHECK FOR THE EXISTENCE OF THE VARIANT SELECTED

    perform zf_check_var_exist.

    at selection-screen on value-request for d_vari.

    • PROVIDE THE F4-HELP.

    perform zf_variant_f4.

    *START OF SELECTION.

    start-of-selection.

    perform z_select.

    perform check_validation_flag.

    perform z_fieldcat using i_fieldcat.

    perform z_layout.

    perform z_sortinfo using i_sortinfo.

    perform z_eventcat using i_eventcat.

    perform z_gridtitle.

    perform z_listheader using i_listheader.

    perform z_display.

    &----


    *& Form Z_VALIDATIONS

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form z_validations .

    select vbeln into v_vbeln

    up to 1 rows

    from vbak

    where vbeln in s_vbeln.

    endselect.

    if sy-subrc <> 0.

    message i002(sy) with 'No Records'.

    v_flag = 'X'.

    endif.

    endform. " Z_VALIDATIONS

    &----


    *& Form Z_FIELDCAT

    &----


    • text

    ----


    • -->P_I_FIELDCAT text

    ----


    form z_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.

    data: i_fieldcat type slis_fieldcat_alv.

    *VBAK-VELN

    i_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-key = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.

    i_fieldcat-just = 'C'. " FOR JUSTIFICATION.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'SALES ORDER'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 15. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'VBAK'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.

    append i_fieldcat to p_i_fieldcat.

    *VBAP-SPRAS

    i_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'SPRAS'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'LANGUAGE'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 5. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'TVAUT'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *VBAP-AUGRU

    i_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'AUGRU'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'REASON'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 5. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'VBAK'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *VBAP-bezei

    i_fieldcat-col_pos = '4'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'BEZEI'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'DESCRIPTION'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 20. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'TVAUT'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *VBAP-POSNR

    i_fieldcat-col_pos = '5'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'POSNR'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'ITEM'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 8. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'VBAP'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *VBAP-MATNR.

    i_fieldcat-col_pos = '6'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'MATNR'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'MATERIAL'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 10. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'VBAP'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *VBAP-ZMENG

    i_fieldcat-col_pos = '7'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'ZMENG'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'QUANT'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 10. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'VBAP'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *MAKT-MAKTX

    i_fieldcat-col_pos = '8'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'MAKTX'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'DESCRIPTION'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 20. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'MAKT'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *LIPS-VBELN

    i_fieldcat-col_pos = '9'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'DELIVERY'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 15. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'LIPS'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *LIPS-LFIMG

    i_fieldcat-col_pos = '10'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'LFIMG'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-do_sum = 'X'.

    i_fieldcat-seltext_l = 'LFIMG'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'LIPS'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *parvw

    i_fieldcat-col_pos = '11'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'PARVW'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'PARTNER FUN'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'VBPA'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *KUNNR

    i_fieldcat-col_pos = '12'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'KUNNR'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'SHIP'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'VBPA'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    *NAME1

    i_fieldcat-col_pos = '13'. " POSITION OF THE COLUMN.

    i_fieldcat-fieldname = 'NAME1'. " FIELD FOR WHICH CATALOG ID FILLED.

    i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

    i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.

    i_fieldcat-seltext_l = 'NAME'. " LONG TEXT FOR HEADER.

    i_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.

    i_fieldcat-ref_tabname = 'KNA1'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.

    append i_fieldcat to p_i_fieldcat.

    endform. " Z_FIELDCAT

    &----


    *& Form Z_SELECT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form z_select .

    select vbeln

    augru into corresponding fields of table it_vbak

    from vbak

    where vbeln in s_vbeln.

    if sy-subrc = 0.

    select vbeln

    posnr

    matnr

    zmeng into corresponding fields of table it_vbap

    from vbap

    for all entries in it_vbak

    where vbeln = it_vbak-vbeln.

    if sy-subrc = 0.

    select spras

    augru

    bezei into corresponding fields of table it_reason

    from tvaut

    for all entries in it_vbak

    where augru = it_vbak-augru.

    if sy-subrc = 0.

    select vbeln

    parvw

    kunnr into corresponding fields of table it_vbpa

    from vbpa

    for all entries in it_vbak

    where vbeln = it_vbak-vbeln.

    if sy-subrc = 0.

    select kunnr

    name1 into corresponding fields of table it_kna1

    from kna1

    for all entries in it_vbpa

    where kunnr = it_vbpa-kunnr.

    if sy-subrc = 0.

    select posnr

    matnr

    lfimg into corresponding fields of table it_lips

    from lips

    for all entries in it_vbap

    where posnr = it_vbap-posnr.

    if sy-subrc = 0.

    select matnr

    maktx into corresponding fields of table it_makt

    from makt

    for all entries in it_vbap

    where matnr = it_vbap-matnr.

    endif.

    endif.

    endif.

    endif.

    endif.

    else.

    message i002(sy) with 'No Data found'.

    leave list-processing.

    endif.

    if sy-subrc = 0.

    loop at it_vbap into wa_vbap.

    read table it_vbak into wa_vbak with key vbeln = wa_vbap-vbeln binary search.

    if sy-subrc = 0.

    *MOVE DATA INTO IT_FINAL.

    move: wa_vbak-vbeln to wa_final-vbeln,

    wa_vbak-augru to wa_final-augru,

    wa_vbap-posnr to wa_final-posnr,

    wa_vbap-matnr to wa_final-matnr,

    wa_vbap-zmeng to wa_final-zmeng.

    endif.

    read table it_lips into wa_lips with key posnr = wa_final-posnr binary search.

    if sy-subrc = 0.

    move: wa_lips-lfimg to wa_final-lfimg.

    endif.

    read table it_reason into wa_reason with key augru = wa_final-augru binary search.

    if sy-subrc = 0.

    move: wa_reason-spras to wa_final-spras,

    wa_reason-bezei to wa_final-bezei.

    endif.

    read table it_makt into wa_makt with key matnr = wa_final-matnr binary search.

    if sy-subrc = 0.

    move: wa_makt-maktx to wa_final-maktx.

    endif.

    read table it_vbpa into wa_vbpa with key vbeln = wa_final-vbeln binary search.

    if sy-subrc = 0.

    move: wa_vbpa-parvw to wa_final-parvw,

    wa_vbpa-kunnr to wa_final-kunnr.

    endif.

    read table it_kna1 into wa_kna1 with key kunnr = wa_final-kunnr binary search.

    if sy-subrc = 0.

    move: wa_kna1-name1 to wa_final-name1.

    endif.

    append wa_final to it_final.

    clear wa_final.

    endloop.

    endif.

    endform. " Z_SELECT

    &----


    *& Form Z_LAYOUT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form z_layout .

    i_layout-zebra = 'X'.

    i_layout-totals_text = 'Total'(a00).

    i_layout-subtotals_text = 'SubTotal'(a01).

    i_layout-box_tabname = 'IT_FINAL'.

    endform. " Z_LAYOUT

    &----


    *& Form Z_SORTINFO

    &----


    • text

    ----


    • -->P_I_SORTINFO text

    ----


    form z_sortinfo using p_i_sortinfo type slis_t_sortinfo_alv.

    data: i_sortinfo type slis_sortinfo_alv.

    clear i_sortinfo.

    i_sortinfo-spos = '1'.

    i_sortinfo-fieldname = 'VBELN'.

    i_sortinfo-tabname = 'IT_FINAL'.

    i_sortinfo-up = 'X'.

    i_sortinfo-group = 'UL'. " I.E UNDERLINE AFTER EVERY GROUP

    i_sortinfo-subtot = 'X'.

    append i_sortinfo to p_i_sortinfo.

    endform. " Z_SORTINFO

    &----


    *& Form Z_EVENTCAT

    &----


    • text

    ----


    • -->P_I_EVENTCAT text

    ----


    form z_eventcat using p_i_eventcat type slis_t_event.

    data: i_event type slis_alv_event.

    call function 'REUSE_ALV_EVENTS_GET'

    exporting

    i_list_type = 0

    importing

    et_events = p_i_eventcat

    exceptions

    list_type_wrong = 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.

    clear i_event.

    read table p_i_eventcat with key name = slis_ev_top_of_page into

    i_event.

    if sy-subrc = 0.

    move 'TOP_OF_PAGE' to i_event-form.

    append i_event to p_i_eventcat.

    endif.

    read table p_i_eventcat with key name = slis_ev_pf_status_set into i_event.

    if sy-subrc = 0.

    move 'SET_PF_STATUS' to i_event-form.

    append i_event to p_i_eventcat.

    endif.

    clear i_event.

    read table p_i_eventcat into i_event with key name = slis_ev_user_command .

    if sy-subrc = 0.

    move 'USER_COMMAND' to i_event-form.

    append i_event to p_i_eventcat.

    endif.

    endform. " Z_EVENTCAT

    &----


    *& Form Z_DISPLAY

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form z_display .

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    i_callback_program = v_progname

    i_callback_pf_status_set = 'SET_PF_STATUS'

    i_callback_user_command = 'USER_COMMAND'

    i_callback_top_of_page = 'TOP_OF_PAGE'

    i_grid_title = v_gridtitle

    i_save = 'A'

    is_layout = i_layout

    it_fieldcat = i_fieldcat[]

    it_sort = i_sortinfo

    it_events = i_eventcat

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    tables

    t_outtab = it_final

    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. " Z_DISPLAY

    &----


    *& Form Z_GRIDTITLE

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form z_gridtitle .

    v_gridtitle = 'ALV FOR SALES ORDER DISPLAY'.

    endform. " Z_GRIDTITLE

    *TOP OF PAGE.

    form top_of_page.

    call function 'REUSE_ALV_COMMENTARY_WRITE'

    exporting

    it_list_commentary = i_listheader.

    endform. "TOP_OF_PAGE

    *MENU SETTINGS.

    form set_pf_status using rt_extab type slis_t_extab.

    set pf-status 'ALV_MENU'.

    endform. "SET_PF_STATUS

    *USER-COMMAND

    form user_command using p_ucomm type sy-ucomm

    rs_selfield type slis_selfield.

    data : vbeln type vbeln_va.

    case p_ucomm.

    when 'BACK'.

    leave program.

    when '&IC1'.

    clear : vbeln.

    vbeln = rs_selfield-value.

    set parameter id: 'AUN' field vbeln.

    call transaction 'VA03' and skip first screen.

    endcase.

    endform. " USER_COMMAND

    &----


    *& Form Z_LISTHEADER

    &----


    • text

    ----


    • -->P_I_LISTHEADER text

    ----


    form z_listheader using p_i_listheader type slis_t_listheader.

    data: l_listheader type slis_listheader.

    refresh p_i_listheader.

    clear l_listheader.

    l_listheader-typ = 'H'.

    l_listheader-info = text-001.

    append l_listheader to p_i_listheader.

    clear l_listheader.

    l_listheader-typ = 'H'.

    l_listheader-info = text-002.

    append l_listheader to p_i_listheader.

    endform. " Z_LISTHEADER

    &----


    *& Form check_validation_flag

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form check_validation_flag .

    if not v_flag is initial.

    leave list-processing.

    endif.

    endform. " check_validation_flag

    &----


    *& Form Z_DEFAULT_VARIANT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form z_default_variant .

    i_variant-report = v_progname.

    call function 'REUSE_ALV_VARIANT_DEFAULT_GET'

    exporting

    i_save = 'A'

    changing

    cs_variant = i_variant

    exceptions

    wrong_input = 1

    not_found = 2

    program_error = 3

    others = 4.

    if sy-subrc = 0.

    p_vari = i_variant-variant.

    • D_VARI = P_VARI.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    endif.

    endform. " Z_DEFAULT_VARIANT

    &----


    *& Form ZF_CHECK_VAR_EXIST

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form zf_check_var_exist .

    data: l_variant like disvariant.

    if not p_vari is initial.

    clear l_variant.

    l_variant-report = v_progname.

    l_variant-variant = p_vari.

    call function 'REUSE_ALV_VARIANT_EXISTENCE'

    exporting

    i_save = 'U'

    changing

    cs_variant = l_variant

    exceptions

    wrong_input = 1

    not_found = 2

    program_error = 3

    others = 4.

    if sy-subrc = 0.

    clear i_variant.

    move: l_variant-variant to i_variant-variant,

    l_variant-report to i_variant-report.

    else.

    message id sy-msgid type sy-msgty number sy-msgno

    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    endif.

    endif.

    endform. " ZF_CHECK_VAR_EXIST

    &----


    *& Form ZF_VARIANT_F4

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form zf_variant_f4 .

    data: x_variant like disvariant.

    call function 'REUSE_ALV_VARIANT_F4'

    exporting

    is_variant = i_variant

    • I_TABNAME_HEADER =

    • I_TABNAME_ITEM =

    • IT_DEFAULT_FIELDCAT =

    i_save = 'U'

    i_display_via_grid = 'X'

    importing

    • E_EXIT =

    es_variant = x_variant

    exceptions

    not_found = 1

    program_error = 2

    others = 3

    .

    if sy-subrc = 0.

    p_vari = x_variant-variant.

    d_vari = p_vari.

    clear i_variant.

    move: x_variant-variant to i_variant-variant,

    x_variant-report to i_variant-report.

    else.

    message id sy-msgid type sy-msgty number sy-msgno

    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    endif.

    endform. " ZF_VARIANT_F4

    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.