Application Development 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: 

Changing screen values as per up and down buttons

former_member242512
Participant
0 Kudos

Hi All,

Im new to module pool programming.

I have a requirement if a user enters storage bin, warehouse and storage type the all materials related to such combination should be displayed but 1 at a time on screen.

It should up and down buttons and depending on its press it should display material , description and its quantiy and other details on screen.

Kindly help so as to design such screen . How can make scroll up and down movement which will show single item details at a time on screen.

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Why is this thread still opened? Do you still got issues?

Well, herewith a small example with SCARR table...


DATA: gt_scarr      TYPE STANDARD TABLE OF scarr,       "Data container
      gs_scarr      TYPE scarr,                "Screen output structure
      g_carrid      TYPE scarr-carrid.          "Screen input parameter
 
DATA: g_index       TYPE i,          "Index of the row beeing displayed
      g_maxrows     TYPE i,             "Number of total rows retrieved
      g_okcode      TYPE syucomm,                  "Screen User command
      g_save_okcode TYPE syucomm.
 
CONSTANTS: gc_up    TYPE c VALUE 'U',                "Up button pressed
           gc_dw    TYPE c VALUE 'D'.              "Down button pressed
 

CALL SCREEN 100.
 
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
 MODULE status_0100 OUTPUT.
   SET PF-STATUS 'ST0100'.
 ENDMODULE.                 " STATUS_0100  OUTPUT
 
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
 MODULE user_command_0100 INPUT.
   g_save_okcode = g_okcode.
   CASE g_save_okcode.
     WHEN 'BACK'.
       LEAVE PROGRAM.
     WHEN 'GETDB'.
       PERFORM read_db.
     WHEN 'UP'.
       PERFORM action USING gc_up.
     WHEN 'DOWN'.
       PERFORM action USING gc_dw.
     WHEN OTHERS.
   ENDCASE.
 ENDMODULE.                 " USER_COMMAND_0100  INPUT
 
*&---------------------------------------------------------------------*
*&      Form  action
*&---------------------------------------------------------------------*
 FORM action USING p_action TYPE c.
   IF p_action = gc_up.
     g_index = g_index - 1.
   ELSEIF p_action = gc_dw.
     g_index = g_index + 1.
   ENDIF.
 
  IF g_index < 1.
     g_index = 1.
     MESSAGE s208(00) WITH 'List bottom reached!'.
   ELSEIF g_index > g_maxrows.
     g_index = g_maxrows.
     MESSAGE s208(00) WITH 'No more entries in the list'.
   ENDIF.
 
  READ TABLE gt_scarr INTO gs_scarr INDEX g_index.  "Fetch indexed row
   IF sy-subrc <> 0.
     MESSAGE i208(00) WITH 'No data found' DISPLAY LIKE 'E'.
   ENDIF.
 ENDFORM.                    "action
 
*&---------------------------------------------------------------------*
*&      Form  READ_DB
*&---------------------------------------------------------------------*
 FORM read_db .
   DATA: lt_carrid TYPE RANGE OF scarr-carrid,
         ls_carrid LIKE LINE OF lt_carrid.
 
  CLEAR: gs_scarr, g_maxrows, g_index.
 
  IF g_carrid IS NOT INITIAL.                "Handle input parameter(s)
     ls_carrid-sign   = 'I'.
     IF g_carrid CA '*'.                             "Check for wildcard
       ls_carrid-option = 'CP'.
     ELSE.
       ls_carrid-option = 'EQ'.
     ENDIF.
     ls_carrid-low    = g_carrid.
     APPEND ls_carrid TO lt_carrid.
   ENDIF.
 
  SELECT * FROM scarr INTO TABLE gt_scarr            "Get data from DB
    WHERE carrid IN lt_carrid.
 
  g_maxrows = sy-dbcnt.
 
  PERFORM action USING gc_dw.           "Simulate 1st DOWN button push
 ENDFORM.                    " READ_DB 

Just paste this. Create a screen '100' with 1 input field named G_CARRID of type SCARR-CARRID and 3 output only fields named GS_SCARR-CARRID, GS_SCARR-CONNID, GS_SCARR-URL. Add 3 buttons, the first one with funtion 'GETDB', and two others with function 'UP' and 'DOWN'. In the element list tab of the screen, assign G_OKCODE to screen element OK. Then create the PF-STATUS and add function code 'BACK'. Also, associate the 'UP' and 'DOWN' function keys to PgUp/PgDown.

And there you go...

Hope this helps,

Kr,

m.

6 REPLIES 6

Former Member
0 Kudos

Hi ujjwal,

the way I look with your requirement, you need two screens.

Here's the design I suggest:

First Screen:

Create the following objects:

a. Input for Storage Bin

b. Input for Warehouse

c. Input for Storage Type

d. Command Button for execution

Since you want to show record one at a time, I suggest to use labels just for display purposes.

Second Screen:

a. Labels for Material

b. Labels for Description

c. Labels for Quantity

d. Labels for other details you need to display

e. Two command button (for up and down)

Hope it helps. Cheers

0 Kudos

Hi,

Actually one screen is largely sufficient for that...

On the first button click, you populate an internal table with all material and display the first one found in your custom controls.

On up and down button click, by playing with index you show the appropriate line of your internal table...

Don't forget to check for valid index also: If it reaches 0 or is greater than the actual numbers of material found, display a warning message and reset your index variable accordingly.

Kr,

m.

alex_campbell
Contributor
0 Kudos

I don't know if you can map the up or down keys, but you should be able to map a function code to the PageUp and PageDown keys. In the GUI status, assign the standard toolbar functions for PageUp and PageDown (the icons are a Document with a single Up or Down arrow) to the desired function codes. You can also have Up and Down buttons on the screen which use the same function codes.

Former Member
0 Kudos

Hi,

Why is this thread still opened? Do you still got issues?

Well, herewith a small example with SCARR table...


DATA: gt_scarr      TYPE STANDARD TABLE OF scarr,       "Data container
      gs_scarr      TYPE scarr,                "Screen output structure
      g_carrid      TYPE scarr-carrid.          "Screen input parameter
 
DATA: g_index       TYPE i,          "Index of the row beeing displayed
      g_maxrows     TYPE i,             "Number of total rows retrieved
      g_okcode      TYPE syucomm,                  "Screen User command
      g_save_okcode TYPE syucomm.
 
CONSTANTS: gc_up    TYPE c VALUE 'U',                "Up button pressed
           gc_dw    TYPE c VALUE 'D'.              "Down button pressed
 

CALL SCREEN 100.
 
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
 MODULE status_0100 OUTPUT.
   SET PF-STATUS 'ST0100'.
 ENDMODULE.                 " STATUS_0100  OUTPUT
 
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
 MODULE user_command_0100 INPUT.
   g_save_okcode = g_okcode.
   CASE g_save_okcode.
     WHEN 'BACK'.
       LEAVE PROGRAM.
     WHEN 'GETDB'.
       PERFORM read_db.
     WHEN 'UP'.
       PERFORM action USING gc_up.
     WHEN 'DOWN'.
       PERFORM action USING gc_dw.
     WHEN OTHERS.
   ENDCASE.
 ENDMODULE.                 " USER_COMMAND_0100  INPUT
 
*&---------------------------------------------------------------------*
*&      Form  action
*&---------------------------------------------------------------------*
 FORM action USING p_action TYPE c.
   IF p_action = gc_up.
     g_index = g_index - 1.
   ELSEIF p_action = gc_dw.
     g_index = g_index + 1.
   ENDIF.
 
  IF g_index < 1.
     g_index = 1.
     MESSAGE s208(00) WITH 'List bottom reached!'.
   ELSEIF g_index > g_maxrows.
     g_index = g_maxrows.
     MESSAGE s208(00) WITH 'No more entries in the list'.
   ENDIF.
 
  READ TABLE gt_scarr INTO gs_scarr INDEX g_index.  "Fetch indexed row
   IF sy-subrc <> 0.
     MESSAGE i208(00) WITH 'No data found' DISPLAY LIKE 'E'.
   ENDIF.
 ENDFORM.                    "action
 
*&---------------------------------------------------------------------*
*&      Form  READ_DB
*&---------------------------------------------------------------------*
 FORM read_db .
   DATA: lt_carrid TYPE RANGE OF scarr-carrid,
         ls_carrid LIKE LINE OF lt_carrid.
 
  CLEAR: gs_scarr, g_maxrows, g_index.
 
  IF g_carrid IS NOT INITIAL.                "Handle input parameter(s)
     ls_carrid-sign   = 'I'.
     IF g_carrid CA '*'.                             "Check for wildcard
       ls_carrid-option = 'CP'.
     ELSE.
       ls_carrid-option = 'EQ'.
     ENDIF.
     ls_carrid-low    = g_carrid.
     APPEND ls_carrid TO lt_carrid.
   ENDIF.
 
  SELECT * FROM scarr INTO TABLE gt_scarr            "Get data from DB
    WHERE carrid IN lt_carrid.
 
  g_maxrows = sy-dbcnt.
 
  PERFORM action USING gc_dw.           "Simulate 1st DOWN button push
 ENDFORM.                    " READ_DB 

Just paste this. Create a screen '100' with 1 input field named G_CARRID of type SCARR-CARRID and 3 output only fields named GS_SCARR-CARRID, GS_SCARR-CONNID, GS_SCARR-URL. Add 3 buttons, the first one with funtion 'GETDB', and two others with function 'UP' and 'DOWN'. In the element list tab of the screen, assign G_OKCODE to screen element OK. Then create the PF-STATUS and add function code 'BACK'. Also, associate the 'UP' and 'DOWN' function keys to PgUp/PgDown.

And there you go...

Hope this helps,

Kr,

m.

surajarafath
Contributor
0 Kudos

Try Table Wizard for designing the table

0 Kudos

Thanks a lot for all replies.