Skip to Content
author's profile photo
Former Member

Alv Fields...

HI all,

Can any one let me know how to make the alv output fields editable, and after entering values how to capture and update the db tables.

and can we make multiple fields editable in alv.

Thanks

Zaf

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 11:48 AM

    Check these sample code

    data : begin of it_mara occurs 0,

    mark type flag,

    matnr type matnr,

    mtart type mtart,

    meins type meins,

    end of it_mara.

    data : begin of it_mara1 occurs 0,

    • mark type flag,

    matnr type matnr,

    mtart type mtart,

    meins type meins,

    end of it_mara1.

    data : begin of it_mara2 occurs 0,

    • mark type flag,

    matnr type matnr,

    mtart type mtart,

    meins type meins,

    end of it_mara2.

    data : t_fieldcat type lvc_t_fcat,

    t_fieldcat1 type lvc_t_fcat,

    s_fieldcat like line of t_fieldcat.

    data : s_layout type lvc_s_layo.

    data : control type ref to cl_gui_custom_container,

    grid type ref to cl_gui_alv_grid.

    data: begin of wa ,

    mark type flag,

    matnr type matnr,

    mtart type mtart,

    meins type meins,

    end of wa.

    class lcl_events_box definition.

    public section.

    methods :

    *Handler_Data_Changed for event Data_Changed of cl_gui_alv_grid

    *imporTing er_data_changed,

    *

    Handler_User_Command for event User_Command of cl_gui_alv_grid

    imporTing e_ucomm,

    Handler_ToolBar for event ToolBar of cl_gui_alv_grid

    importing E_object E_interactive.

    endclass.

    class lcl_events_box implementation.

    method Handler_user_command.

    PERFORM FORM_USERCOMMAND CHANGING E_UCOMM.

    endmethod.

    method Handler_ToolBar.

    PERFORM FORM_TOOLBAR CHANGING E_OBJECT E_INTERACTIVE

    E_OBJECT->MT_TOOLBAR.

    endmethod.

    ENDCLASS.

    start-of-selection.

    data : w_events type ref to lcl_events_box.

    select matnr mtart meins from mara into corresponding fields of table

    it_mara.

    call screen 100.

    &----


    *& Module pbo_module OUTPUT

    &----


    • text

    ----


    MODULE pbo_module OUTPUT.

    if GRID is initial.

    CREATE OBJECT CONTROL

    EXPORTING

    CONTAINER_NAME = 'CUST_CTRL'.

    CREATE OBJECT GRID

    EXPORTING

    I_PARENT = CONTROL.

    PERFORM BUILD_CATALOG.

    PERFORM BUILD_CATALOG1.

    PERFORM BUILD_LAYOUT.

    CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTING

    IS_LAYOUT = s_layout

    CHANGING

    IT_OUTTAB = it_mara[]

    IT_FIELDCATALOG = t_fieldcat.

    CREATE OBJECT W_EVENTS.

    SET HANDLER : W_EVENTS->HANDLER_TOOLBAR FOR GRID,

    W_EVENTS->HANDLER_USER_COMMAND FOR GRID.

    CALL METHOD GRID->SET_TOOLBAR_INTERACTIVE.

    ELSE.

    call method grid->refresh_table_display.

    ENDIF.

    ENDMODULE. " pbo_module OUTPUT

    &----


    *& Form BUILD_CATALOG

    FORM BUILD_CATALOG .

    S_FIELDCAT-COL_POS = '1'.

    S_FIELDCAT-FIELDNAME = 'MARK'.

    S_FIELDCAT-CHECKBOX = 'X'.

    S_FIELDCAT-eDIT = 'X'.

    APPEND S_FIELDCAT TO T_FIELDCAT.

    CLEAR S_FIELDCAT.

    S_FIELDCAT-COL_POS = '2'.

    S_FIELDCAT-FIELDNAME = 'MATNR'.

    S_FIELDCAT-SCRTEXT_M = 'MATERIAL'.

    APPEND S_FIELDCAT TO T_FIELDCAT.

    S_FIELDCAT-COL_POS = '3'.

    S_FIELDCAT-FIELDNAME = 'MTART'.

    S_FIELDCAT-SCRTEXT_M = 'MATERL TYPE'.

    APPEND S_FIELDCAT TO T_FIELDCAT.

    S_FIELDCAT-COL_POS = '4'.

    S_FIELDCAT-FIELDNAME = 'MEINS'.

    S_FIELDCAT-SCRTEXT_M = 'UOM'.

    APPEND S_FIELDCAT TO T_FIELDCAT.

    ENDFORM. " BUILD_CATALOG

    &----


    *& Form BUILD_LAYOUT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM BUILD_LAYOUT .

    S_LAYOUT-ZEBRA = 'X'.

    • S_LAYOUT-CWIDTH_OPT = 'X'.

    S_LAYOUT-GRID_TITLE = 'Material Details'.

    ENDFORM.

    " BUILD_LAYOUT////////////////////////////////////

    " USER_COMMAND_0100 INPUT

    &----


    *& Form FORM_USERCOMMAND

    &----


    • text

    ----


    • <--P_E_UCOMM text

    ----


    form FORM_USERCOMMAND changing p_e_ucomm.

    CASE P_E_UCOMM.

    WHEN 'INT1'.

    DO.

    READ TABLE IT_MARA INDEX SY-INDEX TRANSPORTING MARK MATNR.

    IF SY-SUBRC <> 0.

    EXIT.

    ENDIF.

    IF IT_MARA-MARK = 'X'.

    read table it_mara into wa TRANSPORTING MATNR MTART MEINS .

    MOVE-CORRESPONDING WA TO IT_MARA1.

    READ TABLE IT_MARA1 TRANSPORTING MATNR MTART MEINS .

    MOVE-CORRESPONDING IT_MARA1 TO IT_MARA2.

    APPEND IT_MARA2.

    CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTING

    IS_LAYOUT = s_layout

    CHANGING

    IT_OUTTAB = it_mara2[]

    IT_FIELDCATALOG = t_fieldcat1.

    *

    • SET PARAMETER ID 'MAT' FIELD IT_MARA-MATNR.

    • CALL TRANSACTION 'MM02'.

    . ENDIF.

    • ENDIF.

    ENDDO.

    ENDCASE.

    endform. " FORM_USERCOMMAND

    &----


    *& Form FORM_TOOLBAR

    &----


    • text

    ----


    • <--P_E_OBJECT text

    • <--P_E_INTERACTIVE text

    • <--P_E_OBJECT_>MT_TOOLBAR text

    ----


    FORM FORM_TOOLBAR CHANGING P_E_OBJECT TYPE REF TO

    CL_ALV_EVENT_TOOLBAR_SET

    P_E_INTERACTIVE

    MT_TOOLBAR TYPE TTB_BUTTON.

    DATA WAL_BUTTON TYPE STB_BUTTON.

    *WAL_BUTTON-ICON = ICON_status_reverse.

    WAL_BUTTON-TEXT = 'GO'.

    WAL_BUTTON-QUICKINFO = 'PROCEED'.

    waL_button-FUNCTION = 'INT1'.

    WAL_BUTTON-BUTN_TYPE = 0.

    WAL_BUTTON-DISABLED = SPACE.

    insert WAL_BUTTON INTO P_E_OBJECT->MT_TOOLBAR index 1.

    endform. " FORM_TOOLBAR

    &----


    *& Module PF-STATUS OUTPUT

    &----


    • text

    ----


    module PF-STATUS output.

    set pf-status 'Z7PSTAT'.

    endmodule. " PF-STATUS OUTPUT

    &----


    *& Module USER_COMMAND_0100 INPUT

    &----


    • text

    ----


    module USER_COMMAND_0100 input.

    CASE SY-UCOMM.

    WHEN 'BACK'.

    LEAVE PROGRAM.

    WHEN 'CANCEL'.

    LEAVE PROGRAM.

    ENDCASE.

    endmodule. " USER_COMMAND_0100 INPUT

    &----


    *& Form BUILD_CATALOG1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form BUILD_CATALOG1 .

    S_FIELDCAT-COL_POS = '1'.

    S_FIELDCAT-FIELDNAME = 'MATNR'.

    S_FIELDCAT-SCRTEXT_M = 'MATERIAL'.

    APPEND S_FIELDCAT TO T_FIELDCAT1.

    S_FIELDCAT-COL_POS = '2'.

    S_FIELDCAT-FIELDNAME = 'MTART'.

    S_FIELDCAT-SCRTEXT_M = 'MATERL TYPE'.

    APPEND S_FIELDCAT TO T_FIELDCAT1.

    S_FIELDCAT-COL_POS = '3'.

    S_FIELDCAT-FIELDNAME = 'MEINS'.

    S_FIELDCAT-SCRTEXT_M = 'UOM'.

    APPEND S_FIELDCAT TO T_FIELDCAT1.

    endform. " BUILD_CATALOG1

    check the below link may be useful for you

    http://www.sapdevelopment.co.uk/reporting/alvhome.htm

    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf

    Simple ALV report

    http://www.sapgenie.com/abap/controls/alvgrid.htm

    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox

    ALV

    1. Please give me general info on ALV.

    http://www.sapfans.com/forums/viewtopic.php?t=58286

    http://www.sapfans.com/forums/viewtopic.php?t=76490

    http://www.sapfans.com/forums/viewtopic.php?t=20591

    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.

    2. How do I program double click in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=11601

    http://www.sapfans.com/forums/viewtopic.php?t=23010

    3. How do I add subtotals (I have problem to add them)...

    http://www.sapfans.com/forums/viewtopic.php?t=20386

    http://www.sapfans.com/forums/viewtopic.php?t=85191

    http://www.sapfans.com/forums/viewtopic.php?t=88401

    http://www.sapfans.com/forums/viewtopic.php?t=17335

    4. How to add list heading like top-of-page in ABAP lists?

    http://www.sapfans.com/forums/viewtopic.php?t=58775

    http://www.sapfans.com/forums/viewtopic.php?t=60550

    http://www.sapfans.com/forums/viewtopic.php?t=16629

    5. How to print page number / total number of pages X/XX in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)

    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.

    http://www.sapfans.com/forums/viewtopic.php?t=64320

    http://www.sapfans.com/forums/viewtopic.php?t=44477

    7. How can I set the cell color in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=52107

    8. How do I print a logo/graphics in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=81149

    http://www.sapfans.com/forums/viewtopic.php?t=35498

    http://www.sapfans.com/forums/viewtopic.php?t=5013

    9. How do I create and use input-enabled fields in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=84933

    http://www.sapfans.com/forums/viewtopic.php?t=69878

    10. How can I use ALV for reports that are going to be run in background?

    http://www.sapfans.com/forums/viewtopic.php?t=83243

    http://www.sapfans.com/forums/viewtopic.php?t=19224

    11. How can I display an icon in ALV? (Common requirement is traffic light icon).

    http://www.sapfans.com/forums/viewtopic.php?t=79424

    http://www.sapfans.com/forums/viewtopic.php?t=24512

    12. How can I display a checkbox in ALV?

    http://www.sapfans.com/forums/viewtopic.php?t=88376

    http://www.sapfans.com/forums/viewtopic.php?t=40968

    http://www.sapfans.com/forums/viewtopic.php?t=6919

    Go thru these programs they may help u to try on some hands on

    ALV Demo program

    BCALV_DEMO_HTML

    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode

    BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode

    BCALV_GRID_DEMO Simple ALV Control Call Demo Program

    BCALV_TREE_DEMO Demo for ALV tree control

    BCALV_TREE_SIMPLE_DEMO

    BC_ALV_DEMO_HTML_D0100

    Regards,

    rewards point.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 11:47 AM

    In the header line I am giving the 3 column and editable for user.

    I wa_fieldcat-col_pos = '3'.

    wa_fieldcat-fieldname = 'VKUEGRU'.

    wa_fieldcat-edit = 'X'.

    wa_fieldcat-input = 'X'.

    wa_fieldcat-tabname = 'T_HEAD'.

    • wa_fieldcat-drdn_hndl = '1'.

    wa_fieldcat-seltext_l = 'Reason for Cancel'.

    wa_fieldcat-outputlen = '25'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    regards,

    rewards point.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 11:48 AM

    We can make the complete column in the table editable by passing

    wa_fieldcat-edit = 'X'

    wa_fieldcat-input = 'X'.

    .Also we can make particular fields in a output editable if we use the

    FM "'REUSE_ALV_GRID_DISPLAY_LVC'" for grid display or any FM's using grid display. but my requirement is like, i should make particular fields editable in the hierarchical display output (only with hierarchical display).

    regards.

    rewards point.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 11:49 AM

    CHECK below

    &----


    *

    *& Report ZFIR_WRITE_OFF

    &----


    REPORT zfir_write_off

    NO STANDARD PAGE HEADING

    MESSAGE-ID zles.

    ************************************************************************

    • TYPE-POOLS

    ************************************************************************

    TYPE-POOLS:slis.

    ************************************************************************

    • TABLES

    ************************************************************************

    TABLES: kna1, t001, zdunning_data, bsid, t052.

    ************************************************************************

    • INTERNAL TABLES

    ************************************************************************

    • To check for bukrs in selection screen

    DATA: BEGIN OF t_t001 OCCURS 0,

    bukrs TYPE t001-bukrs,

    END OF t_t001.

    • To check for the customer in selection screen

    DATA: BEGIN OF t_kna1 OCCURS 0,

    kunnr TYPE kna1-kunnr,

    name1 TYPE kna1-name1,

    END OF t_kna1.

    *Data from BSID table

    DATA: BEGIN OF t_bsid OCCURS 0,

    bukrs LIKE bsid-bukrs,

    budat LIKE bsid-budat,

    kunnr LIKE bsid-kunnr,

    belnr LIKE bsid-belnr,

    zfbdt LIKE bsid-zfbdt,

    zterm LIKE bsid-zterm,

    dmbtr LIKE bsid-dmbtr,

    waers LIKE bsid-waers,

    vbeln LIKE bsid-vbeln,

    END OF t_bsid.

    *Data from ZDunning_data

    DATA: BEGIN OF t_zdunning OCCURS 0,

    belnr LIKE zdunning_data-belnr,

    kunnr LIKE zdunning_data-kunnr,

    zdef_notice_flg LIKE zdunning_data-zdef_notice_flg,

    zterm_notice_flg LIKE zdunning_data-zterm_notice_flg,

    END OF t_zdunning.

    *Data from t052 for base line days

    DATA: BEGIN OF t_t052 OCCURS 0,

    zterm LIKE t052-zterm,

    ztag1 LIKE t052-ztag1,

    END OF t_t052.

    *with duedate and date for write off calculation

    DATA: BEGIN OF t_data OCCURS 0,

    belnr LIKE bsid-belnr,

    kunnr LIKE bsid-kunnr,

    zterm LIKE bsid-zterm,

    zfbdt LIKE bsid-zfbdt,

    ztag1 LIKE t052-ztag1,

    duedate LIKE bsid-zfbdt,

    wdate LIKE bsid-zfbdt,

    vbeln LIKE bsid-vbeln,

    dmbtr LIKE bsid-dmbtr,

    waers LIKE bsid-waers,

    budat LIKE bsid-budat,

    vbelv like vbfa-vbelv,

    Name1 like kna1-name1,

    END OF t_data.

    *Output display in ALV report

    DATA: BEGIN OF t_output OCCURS 0,

    Flag type C,

    bukrs LIKE bsid-bukrs,

    kunnr LIKE bsid-kunnr,

    vbeln LIKE bsid-vbeln, "Invoice

    posnv like vbfa-posnv,

    wdate LIKE bsid-zfbdt,

    belnr LIKE bsid-belnr,

    dmbtr LIKE bsid-dmbtr,

    waers LIKE bsid-waers,

    budat LIKE bsid-budat,

    vbelv like vbfa-vbelv, "Contract

    name1 like kna1-name1,

    duedate like bsid-zfbdt,

    END OF t_output.

    • To get contract number for the billing document number

    DATA: BEGIN OF t_vbfa OCCURS 0,

    vbelv LIKE vbfa-vbelv,

    vbeln LIKE vbfa-vbeln,

    POSNV like vbfa-POSNV,

    END OF t_vbfa.

    data: begin of t_cust occurs 0,

    KUNNR like kna1-kunnr,

    name1 like kna1-name1,

    end of t_cust.

    data: begin of t_head occurs 0,

    VBELv like vbfa-vbelv,

    posnv like vbfa-posnv,

    VKUEGRU type ZLIST_WO_RCANCEL,

    end of t_head.

    data: begin of it_veda occurs 0,

    VBELn LIKE Veda-VBELN,

    POSNR LIKE Veda-VPOSN,

    VKUEGRU LIKE Veda-VKUEGRU,

    end of it_veda.

    ************************************************************************

    • VARIABLE DECLARATION

    ************************************************************************

    DATA: l_duedate LIKE bsid-zfbdt,

    l_wdate LIKE bsid-zfbdt.

    ************************************************************************

    • VARIABLE FOR ALV DISPLAY

    ************************************************************************

    DATA: t_fieldcat TYPE slis_t_fieldcat_alv,

    wa_fieldcat TYPE slis_fieldcat_alv.

    DATA: t_fieldcat1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,

    wa_fieldcat1 TYPE slis_fieldcat_alv.

    DATA: t_layout TYPE slis_layout_alv.

    DATA: g_repid LIKE sy-repid.

    ************************************************************************

    • SELECTION-SCREEN

    ************************************************************************

    *Selection Screen Parameters for user input

    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

    PARAMETERS:

    *Company Code

    p_bukrs LIKE t001-bukrs OBLIGATORY.

    SELECT-OPTIONS:

    *Customer Number

    s_kunnr FOR kna1-kunnr OBLIGATORY DEFAULT '0' TO 'ZZZZZZZZZZ'.

    PARAMETERS:

    *Write Off Date

    p_wodate TYPE sy-datum OBLIGATORY.

    SELECTION-SCREEN END OF BLOCK b1 .

    ************************************************************************

    • AT SELECTION-SCREEN

    ************************************************************************

    *Selection Screen validation for Company code

    AT SELECTION-SCREEN ON p_bukrs.

    SELECT SINGLE bukrs FROM t001 "#EC *

    INTO t_t001

    WHERE bukrs = p_bukrs.

    IF sy-subrc NE 0.

    *Error message for Invalid Company Code

    MESSAGE e000 WITH text-002.

    ENDIF.

    *Selection Screen Validation for Customer

    AT SELECTION-SCREEN ON s_kunnr.

    IF NOT s_kunnr IS INITIAL.

    SELECT SINGLE kunnr name1

    FROM kna1 "#EC *

    INTO t_kna1

    WHERE kunnr IN s_kunnr.

    IF sy-subrc NE 0.

    *Error message for Invalid Customer Number

    MESSAGE e000 WITH text-003.

    ENDIF.

    ENDIF.

    AT SELECTION-SCREEN ON p_wodate.

    IF p_wodate IS INITIAL.

    p_wodate = sy-datum.

    ENDIF.

    ************************************************************************

    • INITIALIZATION

    ************************************************************************

    INITIALIZATION.

    PERFORM clear_data.

    ************************************************************************

    • START-OF-SELECTION

    ************************************************************************

    START-OF-SELECTION.

    *Get the Accounting Document Number and base line date from BSID

    SELECT bukrs kunnr belnr budat zfbdt zterm dmbtr waers vbeln

    FROM bsid

    INTO corresponding fields of TABLE t_bsid

    WHERE kunnr IN s_kunnr AND

    bukrs = p_bukrs.

    IF NOT t_bsid[] IS INITIAL.

    *Get the Dunning data based on the Accounting Document Number from BSID

    SELECT belnr kunnr zdef_notice_flg zterm_notice_flg

    FROM zdunning_data

    INTO TABLE t_zdunning

    FOR ALL ENTRIES IN t_bsid

    WHERE kunnr = t_bsid-kunnr AND

    belnr = t_bsid-belnr AND

    zdef_notice_flg = 'Y' AND

    zterm_notice_flg = 'Y'.

    *Get the base line days from t052 table based on BSID data

    SELECT zterm ztag1

    FROM t052

    INTO TABLE t_t052

    FOR ALL ENTRIES IN t_bsid

    WHERE zterm = t_bsid-zterm.

    *Calculate the due date(bse line date BSID-ZFBDT + base line days

    *T052-ZTAG )

    IF NOT t_zdunning[] IS INITIAL.

    • Get the customer name

    Select KUNNR NAME1 from KNA1

    INTO table t_cust

    for all entries in t_zdunning

    where kunnr = t_zdunning-kunnr.

    • LOOP AT t_zdunning.

    LOOP AT t_bsid.

    CLEAR t_zdunning.

    READ TABLE t_zdunning WITH KEY belnr = t_bsid-belnr

    kunnr = t_bsid-kunnr.

    CHECK sy-subrc = 0.

    CLEAR t_t052.

    READ TABLE t_t052 WITH KEY zterm = t_bsid-zterm.

    IF sy-subrc = 0 .

    t_data-belnr = t_zdunning-belnr.

    t_data-kunnr = t_zdunning-kunnr.

    Clear t_cust.

    read table t_cust with key kunnr = t_zdunning-kunnr.

    if sy-subrc = 0.

    t_data-name1 = t_cust-name1.

    endif.

    t_data-zterm = t_bsid-zterm.

    t_data-zfbdt = t_bsid-zfbdt.

    t_data-ztag1 = t_t052-ztag1.

    t_data-vbeln = t_bsid-vbeln.

    t_data-dmbtr = t_bsid-dmbtr.

    t_data-waers = t_bsid-waers.

    t_data-budat = t_bsid-budat.

    *calculate duedate

    CLEAR l_duedate.

    l_duedate = t_bsid-zfbdt + t_t052-ztag1.

    t_data-duedate = l_duedate.

    *calculate date for write off

    CLEAR l_wdate.

    l_wdate = l_duedate + 180.

    t_data-wdate = l_wdate.

    APPEND t_data.

    CLEAR l_wdate.

    CLEAR l_duedate.

    ENDIF.

    ENDLOOP.

    ELSE.

    MESSAGE s000 WITH text-005.

    ENDIF.

    *Check the wdate with write off date in the selection screen value.

    *If this calculated date is Greater than value enetred in selection

    *screen, display the corresponding data in ALV report.

    IF NOT t_data[] IS INITIAL.

    SELECT vbelv vbeln

    POSNV

    FROM vbfa

    INTO TABLE t_vbfa

    FOR ALL ENTRIES IN t_data

    WHERE vbeln = t_data-vbeln.

    • and

    • VBTYP_V = 'G'.

    *If reason for cancelation is there, no writeoff.

    Select VBELn VPOSN VKUEGRU from Veda

    into table it_veda

    for all entries in t_vbfa

    where vbeln = t_vbfa-vbelv.

    SELECT vbelv

    POSNV

    FROM vbfa

    INTO TABLE t_Head

    FOR ALL ENTRIES IN t_data

    WHERE vbeln = t_data-vbeln

    • and

    • VBTYP_V = 'G'.

    .

    loop at t_head.

    clear it_veda.

    Read table it_veda with key vbeln = t_head-vbelv

    posnr = t_head-posnv.

    if not it_veda-VKUEGRU is initial.

    Delete t_head where vbelv = it_veda-vbeln and

    posnv = it_veda-posnr.

    endif.

    endloop.

    LOOP AT t_data.

    IF t_data-wdate LE p_wodate.

    t_output-bukrs = p_bukrs.

    t_output-kunnr = t_data-kunnr.

    CLEAR t_vbfa.

    READ TABLE t_vbfa WITH KEY vbeln = t_data-vbeln.

    read table t_head with key vbelv = t_vbfa-vbelv

    posnv = t_vbfa-posnv.

    if sy-subrc = 0.

    t_output-vbelv = t_vbfa-vbelv.

    t_output-posnv = t_vbfa-posnv.

    t_output-name1 = t_data-name1.

    t_output-wdate = t_data-wdate.

    t_output-belnr = t_data-belnr.

    t_output-dmbtr = t_data-dmbtr.

    t_output-waers = t_data-waers.

    t_output-budat = t_data-budat.

    t_output-vbeln = t_data-vbeln.

    t_output-duedate = t_data-duedate .

    APPEND t_output.

    ENDIF.

    clear t_output.

    ENDIF.

    ENDLOOP.

    ELSE.

    MESSAGE s000 WITH text-006.

    ENDIF.

    *ALV display for the output records

    IF NOT t_output[] IS INITIAL.

    PERFORM alv_display.

    ELSE.

    MESSAGE s000 WITH text-006.

    ENDIF.

    ELSE.

    MESSAGE s000 WITH text-004.

    ENDIF.

    &----


    *& Form clear_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM clear_data .

    CLEAR:t_t001,

    t_kna1,

    t_bsid,

    t_zdunning,

    t_t052,

    t_data,

    t_output,

    wa_fieldcat,

    t_layout,

    t_fieldcat,

    t_vbfa.

    REFRESH:t_t001,

    t_kna1,

    t_bsid,

    t_zdunning,

    t_t052,

    t_data,

    t_output,

    t_fieldcat,

    t_vbfa.

    clear:t_head,

    it_veda.

    Refresh:t_head,

    it_veda.

    Clear T_cust.

    Refresh t_data.

    ENDFORM. " clear_data

    &----


    *& Form alv_display

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM alv_display .

    *To build the field catalogue

    PERFORM build_fieldcatalog1.

    PERFORM build_fieldcatalog.

    *To build the ALV layout

    PERFORM build_layout.

    *To displayt the data in ALV report

    PERFORM display_alv_report.

    ENDFORM. " alv_display

    &----


    *& Form build_fieldcatalog

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM build_fieldcatalog1 .

    REFRESH t_fieldcat1.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '1'.

    wa_fieldcat-fieldname = 'VBELV'.

    wa_fieldcat-tabname = 'T_HEAD'.

    wa_fieldcat-seltext_l = 'Contract Number'.

    • wa_fieldcat-Checkbox = 'X'.

    • wa_fieldcat-edit = 'X'.

    • wa_fieldcat-no_out = 'X'.

    wa_fieldcat-outputlen = '15'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '2'.

    wa_fieldcat-fieldname = 'POSNV'.

    wa_fieldcat-tabname = 'T_HEAD'.

    wa_fieldcat-seltext_l = 'Item Number'.

    wa_fieldcat-outputlen = '15'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '3'.

    wa_fieldcat-fieldname = 'VKUEGRU'.

    wa_fieldcat-edit = 'X'.

    wa_fieldcat-input = 'X'.

    wa_fieldcat-tabname = 'T_HEAD'.

    • wa_fieldcat-drdn_hndl = '1'.

    wa_fieldcat-seltext_l = 'Reason for Cancel'.

    wa_fieldcat-outputlen = '25'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    endform.

    FORM build_fieldcatalog .

    • REFRESH t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '4'.

    wa_fieldcat-fieldname = 'KUNNR'.

    wa_fieldcat-tabname = 'T_OUTPUT'.

    wa_fieldcat-seltext_l = 'Customer Number'.

    wa_fieldcat-outputlen = '15'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '5'.

    wa_fieldcat-fieldname = 'NAME1'.

    wa_fieldcat-tabname = 'T_OUTPUT'.

    wa_fieldcat-seltext_l = 'Customer Name'.

    wa_fieldcat-outputlen = '30'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '6'.

    wa_fieldcat-fieldname = 'VBELV'.

    wa_fieldcat-tabname = 'T_OUTPUT'.

    wa_fieldcat-seltext_l = 'Contract Number'.

    wa_fieldcat-outputlen = '20'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '7'.

    wa_fieldcat-fieldname = 'VBELN'.

    wa_fieldcat-tabname = 'T_OUTPUT'.

    wa_fieldcat-seltext_l = 'Invoice No.'.

    wa_fieldcat-outputlen = '10'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '8'.

    wa_fieldcat-fieldname = 'BELNR'.

    wa_fieldcat-tabname = 'T_OUTPUT'.

    wa_fieldcat-seltext_l = 'Acc doc Number'.

    wa_fieldcat-outputlen = '20'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '9'.

    wa_fieldcat-fieldname = 'WAERS'.

    wa_fieldcat-tabname = 'T_OUTPUT'.

    wa_fieldcat-seltext_l = 'Currency'.

    wa_fieldcat-outputlen = '15'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '10'.

    wa_fieldcat-fieldname = 'DMBTR'.

    wa_fieldcat-tabname = 'T_OUTPUT'.

    wa_fieldcat-do_sum = 'X'. "SUM UPON DISPLAY

    wa_fieldcat-datatype = 'CURR'.

    wa_fieldcat-seltext_l = 'Amount'.

    wa_fieldcat-outputlen = '15'.

    APPEND wa_fieldcat TO t_fieldcat.

    CLEAR wa_fieldcat.

    wa_fieldcat-col_pos = '11'.

    wa_fieldcat-fieldname = 'DUEDATE'.

    wa_fieldcat-tabname = 'T_OUTPUT'.

    wa_fieldcat-seltext_l = 'Due Date'.

    wa_fieldcat-outputlen = '20'.

    APPEND wa_fieldcat TO t_fieldcat.

    *

    data: lt_dropdown type lvc_t_drop,

    ls_dropdown type lvc_s_drop.

    • First listbox (handle '1').

    ls_dropdown-handle = '1'.

    ls_dropdown-value = 'KG'.

    append ls_dropdown to lt_dropdown.

    ls_dropdown-handle = '1'.

    ls_dropdown-value = 'G'.

    append ls_dropdown to lt_dropdown.

    • call method g_grid->set_drop_down_table

    • exporting it_drop_down = lt_dropdown.

    ENDFORM. " build_fieldcatalog

    &----


    *& Form build_layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM build_layout .

    t_layout-no_input = 'X'.

    t_layout-colwidth_optimize = 'X'.

    ENDFORM. " build_layout

    &----


    *& Form display_alv_report

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM display_alv_report .

    g_repid = sy-repid.

    data g_keyinfo type SLIS_KEYINFO_ALV.

    g_keyinfo-HEADER01 = 'VBELV'.

    g_keyinfo-ITEM01 = 'VBELV'.

    g_keyinfo-HEADER02 = 'POSNV'.

    g_keyinfo-ITEM02 = 'POSNV'.

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    i_interface_check = 'I'

    i_callback_program = g_repid

    i_callback_pf_status_set = 'SET_STATUS'

    i_callback_user_command = 'USER_COMMAND'

    • is_layout = gs_layout

    it_fieldcat = t_fieldcat[]

    i_default = ' '

    i_save = 'A'

    i_tabname_header = 'T_HEAD'

    i_tabname_item = 'T_OUTPUT'

    • i_structure_name_header = v_headers_table

    • i_structure_name_item = v_items_table

    is_keyinfo = g_keyinfo

    • i_bypassing_buffer = 'X'

    TABLES

    t_outtab_header = t_head[]

    • t_outtab_item = i_result

    t_outtab_item = t_output[]

    EXCEPTIONS

    program_error = 1

    OTHERS = 2.

    REFRESH: t_fieldcat[].

    refresh t_fieldcat1[].

    ENDFORM. " display_alv_report

    form SET_STATUS using extab TYPE slis_t_extab.

    SET PF-STATUS 'ZEO_S1' .

    endform.

    &----


    *& Form Top_Of_Page

    &----


    • Top_Of_Page event in ALV

    ----


    FORM top_of_page .

    DATA: t_header TYPE slis_t_listheader,

    wa_header TYPE slis_listheader.

    • Title

    wa_header-typ = 'H'.

    wa_header-info = ' Write Off Worklist'.

    APPEND wa_header TO t_header.

    CLEAR wa_header.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = t_header.

    ENDFORM. "Top_Of_Page

    ----


    *User Command for the button

    ----


    form user_command using r_ucomm type syucomm

    ls_selfield type SLIS_SELFIELD.

    Break-point.

    case r_ucomm.

    when 'EXEC'.

    data: begin of lt_cancel occurs 0.

    include structure ZCANCEL.

    data end of lt_cancel.

    Clear lt_cancel.

    Refresh lt_cancel.

    • Data: ref1 type ref to cl_gui_alv_grid.

    • CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

    • IMPORTING

    • E_GRID = ref1.

    *

    • call method ref1->check_changed_data.

    loop at t_Head where VKUEGRU is not initial.

    • if ( t_HEAD-VKUEGRU NE '1' ) or

    • ( t_Head-VKUEGRU NE '2' ) or

    • ( t_head-VKUEGRU NE '3' ).

    • Clear t_head-vkuegru.

    • message e000 with text-110.

    • endif.

    lt_cancel-vbeln = t_head-vbelv.

    lt_cancel-posnr = t_head-posnv.

    lt_cancel-VKUEGRU = t_head-VKUEGRU.

    Append lt_cancel.

    Clear lt_cancel.

    Endloop.

    CALL FUNCTION 'ZSD_CNTR_CANCEL'

    TABLES

    zcancel = lt_cancel.

    .

    • message s000 .

    endcase.

    endform.

    regards,

    rewards point.

    Add comment
    10|10000 characters needed characters exceeded