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: 

Select Option(subscreen) in module pool..problem with values entered.

Former Member
0 Kudos

I have a program where i have put a select option in a subscreen 1010 and

called that in screen 501.

Also I have a pushbutton on screen 501 named 'Submit' with fcode 'SBM1'.

What I wanted is that when i click that button,the select query be fired according

to the range in the select option (i.e. int tables s_matnr and s_mtart) and the

corresponding report be displayed.

But the problem i am facing is that...the values entered in the fields are not reflecting in s_matnr or s_mtart initially,but only after it has been executed once(submit button clicked).

So the desired report is being shown only the next time submit button is pressed.

Please tell me a way to get over this problem.

--


main program--

&----


*& Module pool Z10_SBANERJEE_MODULE_MM *

*& *

&----


*& *

*& *

&----


PROGRAM z10_sbanerjee_module_mm NO STANDARD PAGE HEADING LINE-COUNT 36

MESSAGE-ID z10sban.

    • Author :

  • Saurabh Banerjee on 16th August 2007.

    • Description:

  • Module Pool to get range of matnr and mtart

  • from select-options and print report.

----


  • T A B L E S D E C L A R A T I O N

----


TABLES: mara.

&----


  • D A T A D E C L A R A T I O N

&----


--


structure for matnr and mtart--

TYPES: BEGIN OF t_mat,

matnr TYPE matnr, "material no

mtart TYPE mtart, "material type

END OF t_mat.

DATA: it_mat TYPE STANDARD TABLE OF t_mat. "internal table

DATA: wa_mat TYPE t_mat. "work area

DATA: OK_CODE(20). "ok code

DATA: D_ANS. "user choice in exit

--


Custom Selection Subcreen 1010--

SELECTION-SCREEN BEGIN OF SCREEN 1010 AS SUBSCREEN.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_matnr FOR mara-matnr,

s_mtart FOR mara-mtart.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN END OF SCREEN 1010.

&----


*& Module STATUS_0501 OUTPUT

&----


  • text

----


MODULE status_0501 OUTPUT.

SET PF-STATUS 'SBMENU'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0501 OUTPUT

&----


*& Module USER_COMMAND_0501 INPUT

&----


  • text

----


MODULE user_command_0501 INPUT.

CASE OK_CODE.

WHEN 'SBM1'. "submit values for matnr and mtart

--


leaving to list processing--

LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 501.

--


normal list printing using write--

sort it_mat by matnr.

ULINE.

WRITE:/ 'Saurabh's company MATERIAL INFORMATION'

, sy-datum.

ULINE.

WRITE:/10 'Material Number' COLOR 3,40 'Material Type' COLOR 5.

ULINE.

SKIP 2.

--


looping at it_mat to print values--

loop at it_mat into wa_mat.

WRITE:/10 wa_mat-matnr COLOR 3 ,40 wa_mat-mtart COLOR 5.

endloop.

WHEN OTHERS.

ENDCASE.

endmodule. " USER_COMMAND_0501 INPUT

&----


*& Module EXIT_PROGRAM INPUT

&----


  • text

----


module EXIT_PROGRAM input.

-----calling function to confirm before exit--


CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

text_question = 'Do You Really want to Exit?'

text_button_1 = 'Yes'

text_button_2 = 'No'

IMPORTING

answer = d_ans

EXCEPTIONS

text_not_found = 1

OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF d_ans = '1'. "yes

CLEAR wa_mat.

LEAVE PROGRAM.

endif.

endmodule. " EXIT_PROGRAM INPUT

&----


*& Module FILL_VAL INPUT

&----


  • text

----


module FILL_VAL input.

GET PARAMETER ID 'MAT' FIELD S_MATNR-LOW.

GET PARAMETER ID 'MAT' FIELD S_MATNR-HIGH.

-----selecting records for corresponding matnr and mtart--


SELECT matnr

mtart

INTO TABLE IT_MAT

FROM MARA

WHERE MATNR IN S_MATNR AND

MTART IN S_MTART.

--


validating matnr and mtart--

IF SY-SUBRC <> 0.

MESSAGE E004.

ENDIF.

endmodule. " FILL_VAL INPUT

--


screen 501 flow logic--

PROCESS BEFORE OUTPUT.

MODULE STATUS_0501.

call subscreen : SUBSCREEN_1010 including sy-repid '1010'.

PROCESS AFTER INPUT.

MODULE FILL_VAL.

MODULE EXIT_PROGRAM AT EXIT-COMMAND.

MODULE USER_COMMAND_0501.

call subscreen : SUBSCREEN_1010.

2 REPLIES 2

Former Member
0 Kudos

hi bumba,

try this program you will find an answer.

demo_sel_screen_as_subscreen.

thanks,

reward if useful.

Madhura.

Former Member
0 Kudos

well i got my answer....

actually i got the PAI order wrong.

i was calling the sub-screen only after user-command.

so the user-command module was being executed before

the screen was called.

so the values were accepted only after one execution.

<b>Previous code:</b>

PROCESS AFTER INPUT.

MODULE FILL_VAL.

MODULE EXIT_PROGRAM AT EXIT-COMMAND.

MODULE USER_COMMAND_0501. "this before calling subscreen

call subscreen : SUBSCREEN_1010. "subscreen called after user command

<b>Corrected code:</b>

PROCESS AFTER INPUT.

MODULE FILL_VAL.

MODULE EXIT_PROGRAM AT EXIT-COMMAND.

call subscreen : SUBSCREEN_1010. "subscreen called before user command

MODULE USER_COMMAND_0501. "this after calling subscreen

*-Now the values s_matnr are accepted before any user command----*

Thanks to Madhura Nadgaura for the help she provided.