Skip to Content

Show table field (eban-ebakz) as checkbox in alv output and when user selects it, update it in eban as ‘X’.

Hi Friends,


I am using 4 icons in my alv output screen.

Process, select all, deselect all and cancel.

After user selects the checkbox (eban-ebakz), the value of this field becomes X and after user hits process icon these field value of X needs to be updated in table eban against respective Purchase Requisition Nos (eban-banfn) .

I have done the alv output.

I need help from where the user selects the checkbox and hits on process to update in database table eban.

Please someone can help me with the code or logic.

Thanks a lot for ur help.


Regards,

Arijit Barman.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Aug 12, 2016 at 04:17 PM

    Hi arjit,

    although it's already done: Purchasin is a legally responsible process. Doing direct UPDATE oder MODIFY on SAP standard tables is an undocumented process (no change documents, no header time stamp update, no transactional proceeding). You will never be able to trace any errors or changes,

    YOU might be held responsible in case of any issues brought up by legal/financial auditing or investigation.

    It is fine to write a program as you did, but the update process should be done using (prefereably) SAP BAPI functions.

    Best Regards

    Clemens

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 09, 2016 at 01:18 PM

    Is your question about ALV, or about updating the purchase order? Could you also please explain what you have searched and tried.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      You can give a success or information message and if you want to display on the next screen then make your ALV interactive, once your record will be processed, capture the result in a internal table with the details you want to display and call a new ALV, that will display the output of the result.

      thank you!!

  • Posted on Aug 11, 2016 at 04:57 AM

    Hi,

    For ALV refer the following link to meet your requirement,..

    ALV Grid Display with checkbox to process selected records at runtime - Code Gallery - SCN Wiki

    thank you!!

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 16, 2016 at 10:29 AM

    Hi I am sharing my complete prg to update table eban from alv output.


    I only need to show another screen after user selects the rows and click on process.

    The next screen will show.


    Pr No. XXX with line item 00 is changed and updated successfully. Can anyone plz help me how to achieve this. This prg is working fine. I only need help to show the next screen after user action on alv output screen.


    REPORT ZMM_PURREQ_CLOSEUPDT NO STANDARD PAGE HEADING.

    DATA : LV_PR TYPE BANFN,

    LV_TY TYPE BSART,

    LV_DAYS TYPE I,

    LV_WERKS TYPE WERKS_D.

    TYPES: BEGIN OF TY_PR.

    INCLUDE TYPE EBAN.

    TYPES: QTY TYPE BAMNG.

    TYPES: END OF TY_PR.

    DATA : LT_PR TYPE TABLE OF TY_PR,

    ST_PR TYPE TY_PR,

    LT_PR_DUPL TYPE TABLE OF TY_PR,

    ST_PR_DUPL TYPE TY_PR,

    LT_PR_TMP LIKE TABLE OF ST_PR,

    GT_OUTTAB LIKE TABLE OF ST_PR,

    LT_PROCESS LIKE TABLE OF ST_PR,

    LT_PR_TMP1 LIKE TABLE OF ST_PR,

    ST_PR_TMP LIKE ST_PR.

    DATA: LV_AGE TYPE SY-DATUM,

    LV_QTY TYPE BAMNG,

    SELECTALL_FLAG(1) TYPE C.

    *------ OO DATA ----------

    DATA: OKCODE TYPE SY-UCOMM,

    SAVE_OK TYPE SY-UCOMM,

    G_CONTAINER TYPE SCRFNAME VALUE 'PR_DATA' ,

    G_GRID TYPE REF TO CL_GUI_ALV_GRID,

    G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

    GT_FIELDCAT TYPE LVC_T_FCAT,

    GT_FCAT1 LIKE LINE OF GT_FIELDCAT,

    GS_LAYOUT1 TYPE LVC_S_LAYO,

    L_LAYOUT TYPE DISVARIANT,

    LS_EXCLUDE TYPE UI_FUNC,

    L_VALID TYPE C,

    LT_EXCLUDE TYPE UI_FUNCTIONS.

    *---- Selection Screen -----

    SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.

    SELECTION-SCREEN SKIP 1.

    SELECT-OPTIONS :S_PR FOR LV_PR,

    S_TYPE FOR LV_TY OBLIGATORY,

    S_WERKS FOR LV_WERKS OBLIGATORY,

    S_DAYS FOR LV_DAYS NO-EXTENSION NO INTERVALS OBLIGATORY.

    SELECTION-SCREEN END OF BLOCK BLK1.

    START-OF-SELECTION.

    LV_AGE = SY-DATUM - S_DAYS-LOW.

    SELECT * FROM EBAN

    INTO TABLE LT_PR

    WHERE BANFN IN S_PR

    AND BSART IN S_TYPE

    AND WERKS IN S_WERKS

    AND LOEKZ = ''

    AND ESTKZ = 'R'

    AND BADAT LT LV_AGE

    AND EBAKZ = ''.

    CLEAR: ST_PR.

    LOOP AT LT_PR INTO ST_PR.

    LV_QTY = ST_PR-MENGE - ( ST_PR-BSMNG + ST_PR-GMMNG ).

    IF LV_QTY > 0.

    ST_PR-QTY = ST_PR-BSMNG + ST_PR-GMMNG.

    ST_PR_DUPL = ST_PR.

    APPEND ST_PR_DUPL TO LT_PR_DUPL.

    CLEAR: ST_PR_DUPL.

    ENDIF.

    ENDLOOP.

    SORT LT_PR_DUPL BY BANFN.

    REFRESH LT_PR.

    IF LT_PR IS INITIAL.

    LT_PR = LT_PR_DUPL.

    ENDIF.

    END-OF-SELECTION.

    CALL SCREEN 1100.

    *----------------------------------------------------------------------*

    * MODULE PBO OUTPUT

    *----------------------------------------------------------------------*

    *

    *----------------------------------------------------------------------*

    MODULE PBO OUTPUT.

    SET PF-STATUS 'MAIN100'.

    SET TITLEBAR 'MAIN100'.

    IF SELECTALL_FLAG <> 'X'.

    GT_OUTTAB[] = LT_PR[].

    ENDIF.

    IF G_CUSTOM_CONTAINER IS INITIAL.

    PERFORM CREATE_AND_INIT_ALV CHANGING GT_OUTTAB GT_FIELDCAT.

    ENDIF.

    CLEAR SELECTALL_FLAG.

    ENDMODULE. "PBO OUTPUT

    *----------------------------------------------------------------------*

    * MODULE PAI INPUT

    *----------------------------------------------------------------------*

    *

    *----------------------------------------------------------------------*

    MODULE PAI INPUT.

    SAVE_OK = OKCODE.

    CLEAR OKCODE.

    PERFORM MODIFY_DATA.

    CASE SAVE_OK.

    WHEN 'EXIT'.

    PERFORM EXIT_PROGRAM.

    WHEN 'PROCESS'.

    PERFORM PROCESS TABLES GT_OUTTAB LT_PROCESS.

    WHEN 'SELECTALL'.

    PERFORM SELECTALL.

    WHEN 'DESELALL'.

    PERFORM DESELECTALL.

    WHEN OTHERS.

    * DO NOTHING

    ENDCASE.

    CLEAR SAVE_OK.

    ENDMODULE. "PAI INPUT

    *---------------------------------------------------------------------*

    * FORM EXIT_PROGRAM *

    *---------------------------------------------------------------------*

    FORM EXIT_PROGRAM.

    LEAVE TO SCREEN 0.

    ENDFORM. "exit_program

    *&---------------------------------------------------------------------*

    *& Form BUILD_FIELDCAT

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * <--P_GT_FIELDCAT text

    *----------------------------------------------------------------------*

    FORM BUILD_FIELDCAT1 CHANGING PT_FIELDCAT TYPE LVC_T_FCAT.

    PERFORM ALV_FIELD_CATAGORY USING 'EBAKZ' TEXT-003 '01' 'X' 'X' 'X' 'X' ''.

    PERFORM ALV_FIELD_CATAGORY USING 'BANFN' TEXT-004 '10' 'X' '' '' '' ''.

    PERFORM ALV_FIELD_CATAGORY USING 'BNFPO' TEXT-006 '06' 'X' '' '' '' ''.

    PERFORM ALV_FIELD_CATAGORY USING 'MATNR' TEXT-013 '18' 'X' '' '' '' ''.

    PERFORM ALV_FIELD_CATAGORY USING 'TXZ01' TEXT-015 '40' 'X' '' '' '' ''.

    PERFORM ALV_FIELD_CATAGORY USING 'WERKS' TEXT-014 '06' 'X' '' '' '' ''.

    PERFORM ALV_FIELD_CATAGORY USING 'MENGE' TEXT-005 '06' 'X' '' '' '' ''.

    PERFORM ALV_FIELD_CATAGORY USING 'QTY' TEXT-033 '06' 'X' '' '' '' ''.

    PERFORM ALV_FIELD_CATAGORY USING 'BADAT' TEXT-007 '10' 'X' '' '' '' ''.

    ENDFORM. "BUILD_FIELDCAT

    *&---------------------------------------------------------------------*

    *& Form CREATE_AND_INIT_ALV

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * <--P_GT_OUTTAB text

    * <--P_GT_FIELDCAT text

    * <--P_GS_LAYOUT text

    *----------------------------------------------------------------------*

    FORM CREATE_AND_INIT_ALV CHANGING PT_OUTTAB LIKE GT_OUTTAB[]

    PT_FIELDCAT TYPE LVC_T_FCAT.

    * Create an instance of ALV grid control, attach to custom container for full screen.

    CREATE OBJECT G_GRID

    EXPORTING

    I_PARENT = CL_GUI_CUSTOM_CONTAINER=>SCREEN0.

    L_LAYOUT-REPORT = SY-REPID.

    * Build fieldcat and set column WUNIT edit enabled. Assign a handle for the dropdown listbox.

    PERFORM BUILD_FIELDCAT1 CHANGING PT_FIELDCAT.

    * Optionally restrict generic functions to 'change only'. (The user shall not be able to add new lines).

    PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.

    **-- Register Events to

    * PERFORM register_edit.

    GS_LAYOUT1-NO_ROWMARK = 'X'.

    GS_LAYOUT1-COL_OPT = 'X'.

    GS_LAYOUT1-ZEBRA = 'X'.

    SORT GT_OUTTAB BY BANFN BNFPO.

    CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTING

    IS_LAYOUT = GS_LAYOUT1

    IS_VARIANT = L_LAYOUT

    I_SAVE = 'A'

    IT_TOOLBAR_EXCLUDING = LT_EXCLUDE

    CHANGING

    IT_FIELDCATALOG = PT_FIELDCAT

    IT_OUTTAB = PT_OUTTAB.

    ENDFORM. "CREATE_AND_INIT_ALV

    *&---------------------------------------------------------------------*

    *& Form EXCLUDE_TB_FUNCTIONS

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * <--P_LT_EXCLUDE text

    *----------------------------------------------------------------------*

    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.

    * Only allow to change data not to create new entries (exclude generic functions).

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.

    APPEND LS_EXCLUDE TO PT_EXCLUDE.

    ENDFORM. "EXCLUDE_TB_FUNCTIONS

    *&---------------------------------------------------------------------*

    *& Form PROCESS

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * -->P_GT_OUTTAB text

    * -->P_LT_PROCESS text

    *----------------------------------------------------------------------*

    FORM PROCESS TABLES P_GT_OUTTAB STRUCTURE ST_PR

    P_LT_PROCESS STRUCTURE ST_PR.

    CLEAR P_LT_PROCESS[] .

    P_LT_PROCESS[] = P_GT_OUTTAB[].

    LT_PR_TMP[] = P_GT_OUTTAB[].

    SORT LT_PR_TMP BY BANFN BNFPO.

    DELETE LT_PR_TMP WHERE EBAKZ NE 'X'.

    DELETE ADJACENT DUPLICATES FROM LT_PR_TMP COMPARING BANFN.

    SORT GT_OUTTAB BY BANFN BNFPO.

    SORT P_GT_OUTTAB BY BANFN BNFPO.

    SORT P_LT_PROCESS BY BANFN BNFPO.

    DELETE P_LT_PROCESS WHERE EBAKZ NE 'X'.

    LOOP AT LT_PR_TMP INTO ST_PR_TMP.

    AUTHORITY-CHECK OBJECT 'M_BEST_WRK'

    ID 'WERKS' FIELD ST_PR_TMP-WERKS.

    IF SY-SUBRC <> 0.

    MESSAGE E015(ZMSG) WITH ST_PR_TMP-WERKS.

    ENDIF.

    ENDLOOP.

    PERFORM MODIFY_DATA.

    PERFORM UPDATE_DATA.

    ENDFORM. "PROCESS

    *&---------------------------------------------------------------------*

    *& Form ALV_FIELD_CATAGORY

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * -->P_0183 text

    * -->P_0184 text

    * -->P_0185 text

    * -->P_0186 text

    * -->P_0187 text

    * -->P_0188 text

    * -->P_0189 text

    * -->P_0190 text

    *----------------------------------------------------------------------*

    FORM ALV_FIELD_CATAGORY USING VALUE(P_FIELDNAME) TYPE ANY

    VALUE(P_SELTEXT) TYPE ANY

    VALUE(P_LEN) TYPE ANY

    VALUE(P_KEY) TYPE ANY

    VALUE(P_EDIT) TYPE ANY

    VALUE(P_CHECKBOX) TYPE ANY

    VALUE(P_COL_OPT) TYPE ANY

    VALUE(P_NO_OUT) TYPE ANY.

    CLEAR:GT_FCAT1.

    GT_FCAT1-FIELDNAME = P_FIELDNAME.

    GT_FCAT1-REPTEXT = P_SELTEXT.

    GT_FCAT1-OUTPUTLEN = P_LEN.

    GT_FCAT1-KEY = P_KEY.

    GT_FCAT1-EDIT = P_EDIT.

    GT_FCAT1-CHECKBOX = P_CHECKBOX.

    GT_FCAT1-COL_OPT = P_COL_OPT.

    GT_FCAT1-NO_OUT = P_NO_OUT.

    APPEND GT_FCAT1 TO GT_FIELDCAT.

    ENDFORM. "ALV_FIELD_CATAGORY

    *&---------------------------------------------------------------------*

    *& Form SELECTALL

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    FORM SELECTALL.

    SELECTALL_FLAG = 'X'.

    CLEAR: ST_PR.

    SORT GT_OUTTAB BY BANFN BNFPO.

    LOOP AT GT_OUTTAB INTO ST_PR.

    ST_PR-EBAKZ = 'X'.

    MODIFY GT_OUTTAB INDEX SY-TABIX FROM ST_PR TRANSPORTING EBAKZ.

    ENDLOOP.

    CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY.

    ENDFORM. "DO_SELECT_ALL

    *&---------------------------------------------------------------------*

    *& Form DESELECT_ALL

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * --> p1 text

    * <-- p2 text

    *----------------------------------------------------------------------*

    FORM DESELECTALL.

    CLEAR: ST_PR.

    SORT GT_OUTTAB BY BANFN BNFPO.

    LOOP AT GT_OUTTAB INTO ST_PR WHERE EBAKZ = 'X'.

    ST_PR-EBAKZ = ''.

    MODIFY GT_OUTTAB INDEX SY-TABIX FROM ST_PR TRANSPORTING EBAKZ.

    ENDLOOP.

    CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY.

    ENDFORM. "DESELECT_ALL

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * --> p1 text

    * <-- p2 text

    *----------------------------------------------------------------------*

    FORM MODIFY_DATA.

    SORT GT_OUTTAB BY BANFN BNFPO.

    CALL METHOD G_GRID->CHECK_CHANGED_DATA

    IMPORTING

    E_VALID = L_VALID.

    IF L_VALID EQ 'X'.

    CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY.

    ENDIF.

    ENDFORM. "MODIFY_DATA

    *&---------------------------------------------------------------------*

    *& Form UPDATE_DATA

    *&---------------------------------------------------------------------*

    * text

    *----------------------------------------------------------------------*

    * --> p1 text

    * <-- p2 text

    *----------------------------------------------------------------------*

    FORM UPDATE_DATA.

    CLEAR: ST_PR.

    SORT GT_OUTTAB BY BANFN BNFPO.

    LOOP AT GT_OUTTAB INTO ST_PR WHERE EBAKZ = 'X'.

    MODIFY EBAN FROM ST_PR.

    ENDLOOP.

    IF SY-SUBRC = 0.

    MESSAGE 'Selected PRs has been changed and updated successfully' TYPE 'S'.

    ENDIF.

    ENDFORM. "UPDATE_DATA

    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.