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

Regarding table control select option 'X'

former_member227510
Participant
0 Likes
1,792

I have displayed the records corresponding to the field mtart in a table control. when I enter the value food into mtart I am populating the records for the fields matnr, ersda, ernam, laeda. I get all the values for these fields corresponding to the material type food.

My question is as follows:

when I select a particular record from the table control , I want to display it in another screen or program o/p.

when I click on DETAILS, I want that particular fields i.e matnr, ernam, ersda, laeda to be displayed on another screen or program output.

Kindly find the screen shot attached.

how to implement it using call transaction and submit report?

Thanx.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,396

Hi

You must have USER_COMMAND module in PAI, and every button on your screen assigned a function code, right?

So
MODULE USER_COMMAND.

      CASE OK_CODE.

       WHEN 'DETAIL'.

            LOOP AT itab WHERE mark EQ 'X'.

                  SET PARAMETER ID 'FF' FIELD wa_itab-matnr. " or using ABAP memory, EXPORT wa_itab TO MEMORY ID 'JJ'. then in your report IMPORT this memory.

                  CALL STRANSACTION 'ABC'. "or SUBMIT report.

             ENDLOOP.

ENDMODULE.

Regards,

Archer

10 REPLIES 10
Read only

Former Member
0 Likes
1,396

Hi,

your table-control should have a mark-column (e.g. VIM_MARKED in generated maintenance-dialogues). On User-Command (PAI) evaluate your marked-line(s), select additional data, or compose it from already read data and call the next Screen...

maybe you want to take a look on a two-step-maintenance-dialogue.

regards

Jan Martin

Read only

Former Member
0 Likes
1,397

Hi

You must have USER_COMMAND module in PAI, and every button on your screen assigned a function code, right?

So
MODULE USER_COMMAND.

      CASE OK_CODE.

       WHEN 'DETAIL'.

            LOOP AT itab WHERE mark EQ 'X'.

                  SET PARAMETER ID 'FF' FIELD wa_itab-matnr. " or using ABAP memory, EXPORT wa_itab TO MEMORY ID 'JJ'. then in your report IMPORT this memory.

                  CALL STRANSACTION 'ABC'. "or SUBMIT report.

             ENDLOOP.

ENDMODULE.

Regards,

Archer

Read only

0 Likes
1,396

Hi Dengyong,

I am new to abap. can you just send me an example for the same. I am pasting my code.

Just go through the first two-three paras and the last which are bold... I am using a submit ztcdetails report statement. I am unable to link the screen 9000 Details button to the report program. what code should I write within ztcdetails to get the selected mark_column details as per my query.

Thanks and regards.

Gopa

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

*& Report  ZTCGOPAIT2

*&

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

*&

*&

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

report  ztcgopait2.

tables mara.

types: begin of st_mara,

  matnr type matnr,

  ersda type ersda,

  ernam type ernam,

  laeda type laeda,

  sel type boolean,

  end of st_mara.

data: it_mara type table of st_mara,

      wa_mara type st_mara.

call screen 9000.

*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_MARA' ITSELF

controls: tc_mara type tableview using screen 9000.

*&SPWIZARD: LINES OF TABLECONTROL 'TC_MARA'

data:     g_tc_mara_lines  like sy-loopc.

data:     ok_code like sy-ucomm.

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

*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR

module tc_mara_change_tc_attr output.

  describe table it_mara lines tc_mara-lines.

endmodule.                    "TC_MARA_CHANGE_TC_ATTR OUTPUT

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

*&SPWIZARD: GET LINES OF TABLECONTROL

module tc_mara_get_lines output.

  g_tc_mara_lines = sy-loopc.

endmodule.                    "TC_MARA_GET_LINES OUTPUT

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

*&SPWIZARD: MODIFY TABLE

module tc_mara_modify input.

  modify it_mara

    from wa_mara

    index tc_mara-current_line.

endmodule.                    "TC_MARA_MODIFY INPUT

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

*&SPWIZARD: MARK TABLE

module tc_mara_mark input.

  data: g_tc_mara_wa2 like line of it_mara.

  if tc_mara-line_sel_mode = 1

  and wa_mara-sel = 'X'.

    loop at it_mara into g_tc_mara_wa2

      where sel = 'X'.

      g_tc_mara_wa2-sel = ''.

      modify it_mara

        from g_tc_mara_wa2

        transporting sel.

    endloop.

  endif.

  modify it_mara

    from wa_mara

    index tc_mara-current_line

    transporting sel.

endmodule.                    "TC_MARA_MARK INPUT

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

*&SPWIZARD: PROCESS USER COMMAND

module tc_mara_user_command input.

  ok_code = sy-ucomm.

  perform user_ok_tc using    'TC_MARA'

                              'IT_MARA'

                              'SEL'

                     changing ok_code.

  sy-ucomm = ok_code.

endmodule.                    "TC_MARA_USER_COMMAND INPUT

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

*   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.                                          "fcode_tc_mark_lines

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

*&      Module  STATUS_9000  OUTPUT

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

*       text

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

module status_9000 output.

  set pf-status 'MAIN'.

  set titlebar 'MAIN'.

endmodule.                 " STATUS_9000  OUTPUT

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

*&      Module  USER_COMMAND_9000  INPUT

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

*       text

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

module user_command_9000 input.

  case: sy-ucomm.

    when 'ENTER'.

      select matnr

        ersda

        ernam

        laeda

        from mara

        into table it_mara

        where mtart = mara-mtart.

    when 'BACK'.

      leave program.

    when 'MM03'.

      call transaction 'MM03' and skip first screen.

  endcase.

endmodule.                 " USER_COMMAND_9000  INPUT

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

*  MODULE USER_COMMAND

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

*

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

module user_command input.

  case ok_code.

    when 'DETAILS'.

      loop at it_mara into wa_mara where sel eq 'X'.

        set parameter id 'FF' field wa_mara-matnr.

        submit ztcdetails.

      endloop.

  endcase.

endmodule.                    "USER_COMMAND

Read only

Former Member
0 Likes
1,396

Hi,

depending on your program, e.g. modulepool, functiongroup,... i would declare a new dynpro. If you want to reuse this "Detail" Screen in other programs, maybe you should think about wrapping this Screen into a function module. i would not suggest to use set/get parameter or memory ids unless you already got this Screen and its logic already implemented in a Report that you can use. If you are programming from the scratch go with a Screen, if its only used in this context, or with a function module.

regards

Jan Martin 

Read only

fredericbasilius
Participant
0 Likes
1,396

Hi Gopakumar,

Is your requirement is to provide a button in table control,and view the details while clicking the button, in a modal dialog box ?

Regards,

FB

Read only

0 Likes
1,396

Hi Fredric.

dialog box is also good ... or a normal screen will also be okay... my issue is that the values are not being populated in the ztcdetails o/p after call transaction...

thanx

gopa

Read only

former_member227510
Participant
0 Likes
1,396

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

*&      Module  USER_COMMAND_9000  INPUT

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

*       text

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

MODULE user_command_9000 INPUT.

  CASE: sy-ucomm.

    WHEN 'ENTER'.

      SELECT matnr

        ersda

        ernam

        laeda

        FROM mara

        INTO TABLE it_mara

        WHERE mtart = mara-mtart.

    WHEN 'BACK'.

      LEAVE PROGRAM.

    WHEN 'MM03'.

      CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

    WHEN 'DETAILS'.

      LOOP AT it_mara INTO wa_mara WHERE sel EQ 'X'.

        SET PARAMETER ID 'MAT' FIELD wa_mara-matnr. " or using ABAP memory, EXPORT wa_itab TO MEMORY ID 'JJ'. then in your report IMPORT this memory.

        call transaction 'ZTCDETAILS' USING IT_MARA.

      ENDLOOP.

  ENDCASE.

ENDMODULE.

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

*& Report  ZTCDETAILS

*&

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

*&

*&

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

report  ztcdetails.

tables : mara.

types: begin of st_mara,

  matnr type matnr,

  ersda type ersda,

  ernam type ernam,

  laeda type laeda,

  sel type boolean,

  end of st_mara.

data: it_mara type table of st_mara,

      wa_mara type st_mara.

selection-screen begin of block b1 with frame title text-001.

parameter p_matnr type mara-matnr.

selection-screen end of block b1.

select single

matnr

ersda

ernam

laeda

into wa_mara

from mara

where matnr = p_matnr.

  write:/1 wa_mara-matnr,

  10 wa_mara-ersda,

  30 wa_mara-ernam,

  45 wa_mara-laeda.

Read only

former_member227510
Participant
0 Likes
1,396

Hi friends,

got the desired output. I changed the complete code in ztcdetails. It would be great if I get the solution this way... i.e. through above code... worked for nearly 14 hrs on the same... thank you for the support....

Regards,

Gopa

Read only

0 Likes
1,396

did u get the result or not?

Read only

0 Likes
1,396

Hi Abdul,

I got the result as per my desired requirements. Today morning I tried the other two options and the above pasted codes. understood my errors.  Thank you for the support.

Regards,

Gopa