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

Table control in report program

Former Member
0 Likes
2,384

Hi all...

Please help me to create a table control in my report program. my requirement is to enable the user to enter two fields (company code and cost center) on the selection screen. I wish to do this using table control..

example codes will be extremely helpful..

Thanks in advance..

-Pranati.

18 REPLIES 18
Read only

Former Member
0 Likes
1,883

Hi ,

are you sure of your requirement.

you are talking about selection screen or table control.

strange requirement

thanks

Read only

Former Member
0 Likes
1,883

Do you want SELECT-OPTIONS?

Rob

Read only

0 Likes
1,883

Hi,

i had thought about select options, but am afraid it wont work, because, the user wants it as two fields, and is not sure about the number of entries...So i heard about table control.. Any way to do this using table control..

company code / cost center

1234 / qwer123

3456 / dffd 234

7988 / zcpr453

this is how i would like it to be..

Thanks

Pranati

Message was edited by:

pranati dalvi

Read only

0 Likes
1,883

So for each company code, the user has to enter exactly one cost center?

Rob

Read only

0 Likes
1,883

Hi Rob,

Yes, that is how i want it ...

Thanks,

-Pranati

Read only

0 Likes
1,883

Hi all,

can i input values to a program through table in a table control...if yes, how can i do it in a table control created using wizard..

Please help..

Thanks in advance.

-Pranati

Read only

0 Likes
1,883

Hello Pranati,

Why dont you present the user with table control when he runs the report or enters the transaction.

When he runs the report , the user will be presented eith table control as desired.

After user enter the values, end presses the return button, move those values to an internal table in your program. Based on the values in internal table, make the further selections/operations as desired.

Regards

Read only

0 Likes
1,883

Hi Kesi,

I have a put a button on my report selection screen, when the user clicks it, a table will be displayed with two columns cost center and company code. these are input only. I have a internal table also in the program corresponding to this company code and cost center . but the values i put in the table is not coming to the internal table.....I am perplexed... can u please advice..

Thanks

Pranati

Read only

0 Likes
1,883

Hello Praanti,

Can you post the code please so that i can change/modify the required logic.

Regards

Read only

0 Likes
1,883

Hello Pranati,

I have developed some code.

It just displays a table control and after entering the values init, upon hitting the return button, the values will be put into table itab. Have a look and make necessary changes as you see fit.


*&---------------------------------------------------------------------*
*& Report  ZMADHU_TBCNTL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zmadhu_tbcntl.

DATA: BEGIN OF itab OCCURS 0,
     sel TYPE s_flag,
     matnr TYPE matnr,
     ersda TYPE ersda,
     ernam TYPE ernam,
  END OF itab.
CONTROLS: tab_cntl TYPE TABLEVIEW USING SCREEN 100.
*START-OF-SELECTION.
CALL SCREEN 100.

*END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'TABCNTL'.   "pf status
*  SET TITLEBAR 'xxx'.

  CASE sy-ucomm.
    WHEN 'BACK' OR
         'CANCEL' OR
         'EXIT'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  ITAB_MODIFY  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE itab_modify INPUT.
  CASE sy-ucomm .
    WHEN ' '.        " When pressed enter
*  if itab-sel = 'X'.
      MODIFY itab INDEX tab_cntl-current_line.
      APPEND itab.    " append lines to internal table
      CLEAR itab.
*endif.
  ENDCASE.
ENDMODULE.                 " ITAB_MODIFY  INPUT

<u>*Screen 100 flow logic.</u>



PROCESS BEFORE OUTPUT.
  MODULE status_0100.
  LOOP AT itab WITH CONTROL tab_cntl CURSOR
  tab_cntl-current_line..

  ENDLOOP.

PROCESS AFTER INPUT.
  MODULE select_data.
  LOOP .
    CHAIN.
      FIELD itab-matnr.
      FIELD itab-ersda.
      FIELD itab-ernam.
      MODULE itab_modify ON CHAIN-REQUEST.
    ENDCHAIN.
  ENDLOOP.
* MODULE USER_COMMAND_0100.

Award points if helpful

Read only

0 Likes
1,883

Hi Kesi,

I had generated the table control using wizard...

here is the flowlogic..

<i>process before output.

*&spwizard: pbo flow logic for tablecontrol 'COMPCODE'

module compcode_change_tc_attr.

*&spwizard: module COMPCODE_change_col_attr.

loop at l_t_scrntab

with control compcode

cursor compcode-current_line.

module compcode_get_lines.

*&spwizard: module COMPCODE_change_field_attr

endloop.

  • module status_0200.

*

process after input.

*&spwizard: pai flow logic for tablecontrol 'COMPCODE'

loop at l_t_scrntab.

chain.

field l_t_scrntab-bukrs.

field l_t_scrntab-kostl.

module compcode_modify on chain-request.

endchain.

endloop.

module compcode_user_command.

*&spwizard: module COMPCODE_change_tc_attr.

*&spwizard: module COMPCODE_change_col_attr.

  • MODULE USER_COMMAND_0200.</i>

<i>

module COMPCODE_change_tc_attr output.

describe table L_T_SCRNTAB lines COMPCODE-lines.

endmodule.

module compcode_get_lines output.

g_compcode_lines = sy-loopc.

endmodule.

module compcode_modify input.

modify l_t_scrntab

index compcode-current_line.

append l_t_scrntab.

endmodule.

module compcode_user_command input.

ok_code = sy-ucomm.

perform user_ok_tc using 'COMPCODE'

'L_T_SCRNTAB'

' '

changing ok_code.

sy-ucomm = ok_code.

endmodule.</i>

when i executed in the debugging mode i could see that in the at selection screen event, the values are there inthe table , but in the start of selection event it is not coming. ....

Thank you for your code..I tried it...but i cant get it right...

Thanks

Pranati..

Read only

0 Likes
1,883

Hi Kesi,

Thanks a lot.. i have solved the problem.. It was a small problem in my code..

Thanks

Pranati..

Read only

Former Member
0 Likes
1,883

Hi Pranati

u can use select-options & still input 3 or more values in selection-screen.

Pl. declare company code and cost center in select-options.

In selection-screen click on extension button (ICON @ the end of the same line) & input any number of inputs u want.

Lemme know if it worked.

Regards

Read only

Former Member
0 Likes
1,883

Hi,

We can not do the Table control on the selection screen, but we can do the Tab strip control.

To define a tabstrip area with tab pages, use the following statements in your selection screen definition:

SELECTION-SCREEN: BEGIN OF TABBED BLOCK <tab_area> FOR <n> LINES,

TAB (<len>) <tab1> USER-COMMAND <ucom1>

[DEFAULT [PROGRAM <prog>] SCREEN <scrn>],

TAB (<len>) <tab2> USER-COMMAND <ucom2>

[DEFAULT [PROGRAM <prog>] SCREEN <scrn>],

...

END OF BLOCK <tab_area>.

See the below SAP link for the sample programs

http://help.sap.com/saphelp_46c/helpdata/EN/00/deb23789e95378e10000009b38f8cf/content.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/e7/deb237b9a9a968e10000009b38f8cf/content.htm

See the example code

REPORT   znr1 NO STANDARD PAGE HEADING 
            LINE-SIZE 80 LINE-COUNT 60.
TABLES : sscrfields.
DATA  activetab(6) TYPE c .
DATA  mat_des TYPE makt-maktx.
DATA  pl_des  TYPE t001w-name1 .

SELECTION-SCREEN BEGIN OF SCREEN 001 AS SUBSCREEN NO INTERVALS.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-002 NO
INTERVALS.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 14(18) text-002 FOR FIELD matnr.
PARAMETERS matnr TYPE mara-matnr.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN END OF SCREEN 001.
SELECTION-SCREEN BEGIN OF SCREEN 002 AS SUBSCREEN NO INTERVALS.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-003 NO
INTERVALS.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 14(18) text-003 FOR FIELD matnr.
PARAMETERS werks TYPE t001w-werks.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK block2.
SELECTION-SCREEN END OF SCREEN 002.

SELECTION-SCREEN BEGIN OF TABBED BLOCK tabb1 FOR 5 LINES NO INTERVALS.
SELECTION-SCREEN TAB (15) tabs1 USER-COMMAND ucomm1
                     DEFAULT SCREEN 001.
SELECTION-SCREEN TAB (15) tabs2 USER-COMMAND ucomm2.
*                     DEFAULT SCREEN 002   .
SELECTION-SCREEN END OF BLOCK tabb1.
INITIALIZATION.
  tabs1 = text-002.
  tabs2 = text-003.
  activetab = 'TABS1'.
AT SELECTION-SCREEN .
  CASE sscrfields-ucomm.
    WHEN 'UCOMM1'.
      tabb1-prog = sy-repid.
      tabb1-dynnr   = 001.
      tabb1-activetab = 'TABS1'.
      activetab = 'TABS1' .
    WHEN 'UCOMM2'.
      tabb1-prog = sy-repid.
      tabb1-dynnr   = 002.
      tabb1-activetab = 'TABS2'.
      activetab = 'TABS2'.
  ENDCASE.
START-OF-SELECTION.
  CASE activetab.
    WHEN 'TABS1'.
      SELECT SINGLE maktx  FROM makt INTO pl_des WHERE matnr = matnr.
      WRITE: 'Material ' , matnr , mat_des .

    WHEN 'TABS2'.
      SELECT SINGLE name1  FROM t001w INTO pl_des WHERE werks = werks.
      WRITE: 'Plant ' , werks ,pl_des.

Regards

Sudheer

Read only

0 Likes
1,883

Hi Sudheer,

Thanks a lot for your help..I solved it by using table control. Thanks for letting me knw abt tabstrip control.

Pranati..

Read only

Former Member
0 Likes
1,883

Hi all,

The issue is resolved.. so i am closing this thread

Read only

varsha_sap1
Associate
Associate
0 Likes
1,883

Hi Pranati,

I have similar requirement can u please share me the sample code.

Thanks

Varsha

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,883

a "former member" in a 15 year old message, are you optimistic?