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

Getting Approver name and Approval date in module pool program

Former Member
0 Likes
1,245

Hi All,

I am creating module pool for ztable with 2 screen.

1st screen for creating entries, and 2nd screen for approval of created data.

in that approval screen once data approved approver name and approval date i need to updated to ztable.

currently i am using sy-datum and sy-uname for that approvaer name and date field, but i want it like once approval check box enabled then name and date need to updated into the ztable.

for e.g.,  10 entries is their means , i am approving 1st 4 entries so for that 4 data's approval name and date needs to updated in to ztable, for  remaining data's the name and date field should be empty.  but i my case remaining fields also name and date is updating.

how to avoid this, help me

regards,

S.Kavitha

Hi All,

I am creating module pool for ztable with 2 screen.

1st screen for creating entries, and 2nd screen for approval of created data.

in that approval screen once data approved approver name and approval date i need to updated to ztable.

currently i am using sy-datum and sy-uname for that approvaer name and date field, but i want it like once approval check box enabled then name and date need to updated into the ztable.

for e.g.,  10 entries is their means , i am approving 1st 4 entries so for that 4 data's approval name and date needs to updated in to ztable, for  remaining data's the name and date field should be empty.  but i my case remaining fields also name and date is updating.

how to avoid this, help me

regards,

S.Kavitha

6 REPLIES 6
Read only

Former Member
0 Likes
1,193


Hi Kavitha,

Please Provide the code block where you are updating it in ztable.

If you are using table control loop at your internal table check for the checkbox field and modify those records in table..

Regards,

Shashikanth

Read only

Former Member
0 Likes
1,193

Please paste your code.

Read only

0 Likes
1,193

HI ALL,

This code is flowlogic code,

PROCESS BEFORE OUTPUT.

MODULE SELECT_RECORDS.

*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TABLE2'

  MODULE TABLE2_CHANGE_TC_ATTR.

*&SPWIZARD: MODULE TABLE2_CHANGE_COL_ATTR.

  LOOP AT   IT_HFM

       INTO WA_HFM

       WITH CONTROL TABLE2

       CURSOR TABLE2-CURRENT_LINE.

    MODULE TABLE2_GET_LINES.

      MODULE APPROVER_DATA.

*&SPWIZARD:   MODULE TABLE2_CHANGE_FIELD_ATTR

  ENDLOOP.

MODULE USERNAME.

MODULE STATUS_3001.

*

PROCESS AFTER INPUT.

*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TABLE2'

  LOOP AT IT_HFM.

    CHAIN.

      FIELD WA_HFM-RRCTY.

      FIELD WA_HFM-RVERS.

      FIELD WA_HFM-KTOPL.

      FIELD WA_HFM-BUKRS.

      FIELD WA_HFM-RYEAR.

      FIELD WA_HFM-RACCT.

      FIELD WA_HFM-RPMAX.

      FIELD WA_HFM-KOSTL.

      FIELD WA_HFM-ZHFM_GL.

      FIELD WA_HFM-RTCUR.

      FIELD WA_HFM-Z_HFM_LC_BALANCE.

      FIELD WA_HFM-ZAPPROVE.

      FIELD WA_HFM-ERDAT.

      FIELD WA_HFM-ERNAM.

      FIELD ZACINFIT_01-ZAPPROVER_NAME.

      FIELD ZACINFIT_01-ZAPPROVER_DATE.

      MODULE TABLE2_MODIFY ON CHAIN-REQUEST.

    endchain.

    FIELD WA_HFM-MARK

      MODULE TABLE2_MARK ON REQUEST.

     MODULE insert_data1.

*     MODULE APPROVAL.

  ENDLOOP.

  MODULE TABLE2_USER_COMMAND.

    MODULE back AT EXIT-COMMAND.

*&SPWIZARD: MODULE TABLE2_CHANGE_TC_ATTR.

*&SPWIZARD: MODULE TABLE2_CHANGE_COL_ATTR.

MODULE USER_COMMAND_3001.

TYPES:BEGIN OF TY_HFM,

      MARK TYPE C,

      RRCTY TYPE ZACINFIT_01-RRCTY,

      RVERS TYPE ZACINFIT_01-RVERS,

      KTOPL TYPE ZACINFIT_01-KTOPL,

      BUKRS TYPE ZACINFIT_01-BUKRS,

      RYEAR TYPE ZACINFIT_01-RYEAR,

      RACCT TYPE ZACINFIT_01-RACCT,

      RPMAX TYPE ZACINFIT_01-RPMAX,

      KOSTL TYPE ZACINFIT_01-KOSTL,

      ZHFM_GL TYPE ZACINFIT_01-ZHFM_GL,

      RTCUR TYPE ZACINFIT_01-RTCUR,

      Z_HFM_LC_BALANCE TYPE ZACINFIT_01-Z_HFM_LC_BALANCE,

      ZAPPROVE TYPE ZACINFIT_01-ZAPPROVE,

      ERDAT TYPE ZACINFIT_01-ERDAT,

      ERNAM TYPE ZACINFIT_01-ERNAM,

      ZAPPROVER_NAME TYPE ZACINFIT_01-ZAPPROVER_NAME,

      ZAPPROVER_DATE TYPE ZACINFIT_01-ZAPPROVER_DATE,

  END OF TY_HFM.

DATA: IT_HFM LIKE STANDARD TABLE OF ZACINFIT_01,

      WA_HFM LIKE LINE OF IT_HFM.

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TABLE2' ITSELF

CONTROLS: TABLE2 TYPE TABLEVIEW USING SCREEN 3001.

*&SPWIZARD: LINES OF TABLECONTROL 'TABLE2'

DATA:     G_TABLE2_LINES  LIKE SY-LOOPC.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TABLE2'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR

MODULE TABLE2_CHANGE_TC_ATTR OUTPUT.

  DESCRIBE TABLE IT_HFM LINES TABLE2-lines.

ENDMODULE.

*&SPWIZARD: OUTPUT MODULE FOR TC 'TABLE2'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: GET LINES OF TABLECONTROL

MODULE TABLE2_GET_LINES OUTPUT.

  G_TABLE2_LINES = SY-LOOPC.

ENDMODULE.

*&SPWIZARD: INPUT MODULE FOR TC 'TABLE2'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: MODIFY TABLE

MODULE TABLE2_MODIFY INPUT.

  MODIFY IT_HFM

    FROM WA_HFM

    INDEX TABLE2-CURRENT_LINE.

ENDMODULE.

*&SPWIZARD: INPUT MODUL FOR TC 'TABLE2'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: MARK TABLE

MODULE TABLE2_MARK INPUT.

  DATA: g_TABLE2_wa2 like line of IT_HFM.

    if TABLE2-line_sel_mode = 1

    and WA_HFM-MARK = 'X'.

     loop at IT_HFM into g_TABLE2_wa2

       where MARK = 'X'.

       g_TABLE2_wa2-MARK = ''.

       modify IT_HFM

         from g_TABLE2_wa2

         transporting MARK.

     endloop.

  endif.

  MODIFY IT_HFM

    FROM WA_HFM

    INDEX TABLE2-CURRENT_LINE

    TRANSPORTING MARK.

ENDMODULE.

*&SPWIZARD: INPUT MODULE FOR TC 'TABLE2'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: PROCESS USER COMMAND

MODULE TABLE2_USER_COMMAND INPUT.

  OK_CODE = SY-UCOMM.

  PERFORM USER_OK_TC USING    'TABLE2'

                              'IT_HFM'

                              'MARK'

                     CHANGING OK_CODE.

  SY-UCOMM = OK_CODE.

ENDMODULE.

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

*   INCLUDE TABLECONTROL_FORMS                                         *

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

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

*&      Form  USER_OK_TC                                               *

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

FORM USER_OK_TC USING    P_TC_NAME TYPE DYNFNAM

                          P_TABLE_NAME

                          P_MARK_NAME

                 CHANGING P_OK      LIKE SY-UCOMM.

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

   DATA: L_OK              TYPE SY-UCOMM,

         L_OFFSET          TYPE I.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

*&SPWIZARD: Table control specific operations                          *

*&SPWIZARD: evaluate TC name and operations                            *

   SEARCH P_OK FOR P_TC_NAME.

   IF SY-SUBRC <> 0.

     EXIT.

   ENDIF.

   L_OFFSET = STRLEN( P_TC_NAME ) + 1.

   L_OK = P_OK+L_OFFSET.

*&SPWIZARD: execute general and TC specific operations                 *

   CASE L_OK.

     WHEN 'INSR'.                      "insert row

       PERFORM FCODE_INSERT_ROW USING    P_TC_NAME

                                         P_TABLE_NAME.

       CLEAR P_OK.

     WHEN 'DELE'.                      "delete row

       PERFORM FCODE_DELETE_ROW USING    P_TC_NAME

                                         P_TABLE_NAME

                                         P_MARK_NAME.

       CLEAR P_OK.

     WHEN 'P--' OR                     "top of list

          'P-'  OR                     "previous page

          'P+'  OR                     "next page

          'P++'.                       "bottom of list

       PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME

                                             L_OK.

       CLEAR P_OK.

*     WHEN 'L--'.                       "total left

*       PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.

*

*     WHEN 'L-'.                        "column left

*       PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.

*

*     WHEN 'R+'.                        "column right

*       PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.

*

*     WHEN 'R++'.                       "total right

*       PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.

*

     WHEN 'MARK'.                      "mark all filled lines

       PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME

                                         P_TABLE_NAME

                                         P_MARK_NAME   .

       CLEAR P_OK.

     WHEN 'DMRK'.                      "demark all filled lines

       PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME

                                           P_TABLE_NAME

                                           P_MARK_NAME .

       CLEAR P_OK.

*     WHEN 'SASCEND'   OR

*          'SDESCEND'.                  "sort column

*       PERFORM FCODE_SORT_TC USING P_TC_NAME

*                                   l_ok.

   ENDCASE.

ENDFORM.                              " USER_OK_TC

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

*&      Form  FCODE_INSERT_ROW                                         *

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

FORM fcode_insert_row

               USING    P_TC_NAME           TYPE DYNFNAM

                        P_TABLE_NAME             .

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

   DATA L_LINES_NAME       LIKE FELD-NAME.

   DATA L_SELLINE          LIKE SY-STEPL.

   DATA L_LASTLINE         TYPE I.

   DATA L_LINE             TYPE I.

   DATA L_TABLE_NAME       LIKE FELD-NAME.

   FIELD-SYMBOLS <TC>                 TYPE CXTAB_CONTROL.

   FIELD-SYMBOLS <TABLE>              TYPE STANDARD TABLE.

   FIELD-SYMBOLS <LINES>              TYPE I.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

   ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc                     *

   CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body

   ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline

*&SPWIZARD: get looplines of TableControl                              *

   CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.

   ASSIGN (L_LINES_NAME) TO <LINES>.

*&SPWIZARD: get current line                                           *

   GET CURSOR LINE L_SELLINE.

   IF SY-SUBRC <> 0.                   " append line to table

     L_SELLINE = <TC>-LINES + 1.

*&SPWIZARD: set top line                                               *

     IF L_SELLINE > <LINES>.

       <TC>-TOP_LINE = L_SELLINE - <LINES> + 1 .

     ELSE.

       <TC>-TOP_LINE = 1.

     ENDIF.

   ELSE.                               " insert line into table

     L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.

     L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.

   ENDIF.

*&SPWIZARD: set new cursor line                                        *

   L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.

*&SPWIZARD: insert initial line                                        *

   INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.

   <TC>-LINES = <TC>-LINES + 1.

*&SPWIZARD: set cursor                                                 *

   SET CURSOR LINE L_LINE.

ENDFORM.                              " FCODE_INSERT_ROW

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

*&      Form  FCODE_DELETE_ROW                                         *

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

FORM fcode_delete_row

               USING    P_TC_NAME           TYPE DYNFNAM

                        P_TABLE_NAME

                        P_MARK_NAME   .

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

   DATA L_TABLE_NAME       LIKE FELD-NAME.

   FIELD-SYMBOLS <TC>         TYPE cxtab_control.

   FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE.

   FIELD-SYMBOLS <WA>.

   FIELD-SYMBOLS <MARK_FIELD>.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

   ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc                     *

   CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body

   ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline

*&SPWIZARD: delete marked lines                                        *

   DESCRIBE TABLE <TABLE> LINES <TC>-LINES.

   LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header         *

     ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

     IF <MARK_FIELD> = 'X'.

       DELETE <TABLE> INDEX SYST-TABIX.

       IF SY-SUBRC = 0.

         <TC>-LINES = <TC>-LINES - 1.

       ENDIF.

     ENDIF.

   ENDLOOP.

ENDFORM.                              " FCODE_DELETE_ROW

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

*&      Form  COMPUTE_SCROLLING_IN_TC

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

*       text

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

*      -->P_TC_NAME  name of tablecontrol

*      -->P_OK       ok code

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

FORM COMPUTE_SCROLLING_IN_TC USING    P_TC_NAME

                                       P_OK.

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

   DATA L_TC_NEW_TOP_LINE     TYPE I.

   DATA L_TC_NAME             LIKE FELD-NAME.

   DATA L_TC_LINES_NAME       LIKE FELD-NAME.

   DATA L_TC_FIELD_NAME       LIKE FELD-NAME.

   FIELD-SYMBOLS <TC>         TYPE cxtab_control.

   FIELD-SYMBOLS <LINES>      TYPE I.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

   ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get looplines of TableControl                              *

   CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.

   ASSIGN (L_TC_LINES_NAME) TO <LINES>.

*&SPWIZARD: is no line filled?                                         *

   IF <TC>-LINES = 0.

*&SPWIZARD: yes, ...                                                   *

     L_TC_NEW_TOP_LINE = 1.

   ELSE.

*&SPWIZARD: no, ...                                                    *

     CALL FUNCTION 'SCROLLING_IN_TABLE'

          EXPORTING

               ENTRY_ACT             = <TC>-TOP_LINE

               ENTRY_FROM            = 1

               ENTRY_TO              = <TC>-LINES

               LAST_PAGE_FULL        = 'X'

               LOOPS                 = <LINES>

               OK_CODE               = P_OK

               OVERLAPPING           = 'X'

          IMPORTING

               ENTRY_NEW             = L_TC_NEW_TOP_LINE

          EXCEPTIONS

*              NO_ENTRY_OR_PAGE_ACT  = 01

*              NO_ENTRY_TO           = 02

*              NO_OK_CODE_OR_PAGE_GO = 03

               OTHERS                = 0.

   ENDIF.

*&SPWIZARD: get actual tc and column                                   *

   GET CURSOR FIELD L_TC_FIELD_NAME

              AREA  L_TC_NAME.

   IF SYST-SUBRC = 0.

     IF L_TC_NAME = P_TC_NAME.

*&SPWIZARD: et actual column                                           *

       SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.

     ENDIF.

   ENDIF.

*&SPWIZARD: set the new top line                                       *

   <TC>-TOP_LINE = L_TC_NEW_TOP_LINE.

ENDFORM.                              " COMPUTE_SCROLLING_IN_TC

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

*&      Form  FCODE_TC_MARK_LINES

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

*       marks all TableControl lines

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

*      -->P_TC_NAME  name of tablecontrol

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

FORM FCODE_TC_MARK_LINES USING P_TC_NAME

                               P_TABLE_NAME

                               P_MARK_NAME.

*&SPWIZARD: EGIN OF LOCAL DATA-----------------------------------------*

  DATA L_TABLE_NAME       LIKE FELD-NAME.

  FIELD-SYMBOLS <TC>         TYPE cxtab_control.

  FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE.

  FIELD-SYMBOLS <WA>.

  FIELD-SYMBOLS <MARK_FIELD>.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

  ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc                     *

   CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body

   ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline

*&SPWIZARD: mark all filled lines                                      *

  LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header         *

     ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

     <MARK_FIELD> = 'X'.

  ENDLOOP.

ENDFORM.                                          "fcode_tc_mark_lines

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

*&      Form  FCODE_TC_DEMARK_LINES

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

*       demarks all TableControl lines

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

*      -->P_TC_NAME  name of tablecontrol

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

FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME

                                 P_TABLE_NAME

                                 P_MARK_NAME .

*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*

  DATA L_TABLE_NAME       LIKE FELD-NAME.

  FIELD-SYMBOLS <TC>         TYPE cxtab_control.

  FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE.

  FIELD-SYMBOLS <WA>.

  FIELD-SYMBOLS <MARK_FIELD>.

*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

  ASSIGN (P_TC_NAME) TO <TC>.

*&SPWIZARD: get the table, which belongs to the tc                     *

   CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body

   ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline

*&SPWIZARD: demark all filled lines                                    *

  LOOP AT <TABLE> ASSIGNING <WA>.

*&SPWIZARD: access to the component 'FLAG' of the table header         *

     ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.

     <MARK_FIELD> = SPACE.

  ENDLOOP.

ENDFORM.                   

MODULE APPROVER_DATA OUTPUT.

  IF WA_HFM-ZAPPROVE = ''.

    WA_HFM-ZAPPROVER_NAME = ''.

WA_HFM-ZAPPROVER_DATE = ''.

*ELSEIF WA_HFM-ZAPPROVE = 'X'.

*  ZACINFIT_01-ZAPPROVER_NAME = SY-UNAME.

*ZACINFIT_01-ZAPPROVER_DATE = SY-DATUM.

ENDIF.

ENDMODULE.

Read only

0 Likes
1,193

Hi Kavitha,

Please paste code of insert_data1 subrourine,

In this subroutine youo try using below code

Loop at it_hcm into wa_hcm.

if wa_hcm-mark = 'X'.

  modify ZACINFIT from wa_hcm where RRCTY = wa_hcm-RRCTY

Endif.

Endloop.

If RRCTY is the key of ztable otherwise use the all the key fields in where condition.

Regards,

Shashikanth

Read only

0 Likes
1,193

HI SHASHIKANTH ,

MODULE INSERT_DATA1 INPUT.

MODIFY IT_HFM FROM WA_HFM INDEX TABLE2-CURRENT_LINE.

  IF SY-SUBRC <> 0 AND WA_HFM IS NOT INITIAL.

*   MOVE ZACINFIT_01 TO WA_HFM.

    APPEND WA_HFM TO IT_HFM.

   ENDIF.

*  modify zacinfit_01 FROM TABLE it.

MODIFY zacinfit_01 from wa_HFM.

IF SY-SUBRC = 0.

   MESSAGE 'Database updated successfully' type 'S'.

ELSE.

   MESSAGE 'Update Failed' type 'S'.

ENDIF.

ENDMODULE.

Read only

VenkatRamesh_V
Active Contributor
0 Likes
1,193

Hi Kavitha,

CHECK wa_hfm-mark = 'X'.

MODIFY zacinfit_01 from wa_hfm.

Regards,

Venkat.