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: 

User command in subscreen

manish_malakar0316
Active Participant
0 Kudos
3,600

Hi experts,

I have a small issue in my module pool program. I have called a subscreen which contains a table control in my module pool. However in this table control , some additions need to be performed based on the user pressing the ENTER key. The issue is that on pressing ENTER, nothing is happening as the table control is inside a subscreen and  a subscreen does not support user commands. How do I solve this issue so as to perform the addition in my table control? Below are the screen shots for your reference:

1) The variables declared are shown below:

2) Flow logic for screen 9000 is:

3) Inside MODULE USER_COMMAND_9000

4)  Flow logic for table control:

    

5) Inside MODULE READ_THIS.

    

6)     On giving the sales orders and clicking SUBMIT:

    

7)     The table control is displayed in the same screen due to the subscreen REF2 being called:

    

😎     But on giving a value for the column under "NUM" and pressing ENTER, the total "TOT1" is not getting displayed due to the subscreen's property of not supporting user command.

    

So how do I solve this issue and do the calculation? The requirement states that the table control must appear on the same screen below the select-options.

Regards.

Manish.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
2,192

hi manish,

I got the solution for this problem.

what i did is inserted one variable called data_changed (DATA:DATA_CHANGED TYPE N) in

MODULE READ_THIS INPUT.
   IF WA_VBAP IS NOT INITIAL.
     WA_VBAP-TOT1 = WA_VBAP-KWMENG + WA_VBAP-NUM.
     MODIFY IT_VBAP FROM WA_VBAP INDEX TC1-CURRENT_LINE.
     REFRESH CONTROL 'TC1' FROM SCREEN 9002.
     DATA_CHANGED = 1.
   ENDIF.
ENDMODULE.  


when we change value it is changing properly but here in this code it is again generating internal table but with this code it will not allow to again generate internal table due to data_changed value.


MODULE USER_COMMAND_9000 INPUT.
OK_CODE = SY-UCOMM.

CASE OK_CODE.
   WHEN 'SUBMIT'.
   L_DYNPRO = '9002'.

   IF DATA_CHANGED NE '1'.
   SELECT VBELN
          POSNR
          KWMENG
     FROM VBAP
     INTO TABLE IT_VBAP
     WHERE VBELN IN S_VBELN.
     ENDIF.

     CLEAR OK_CODE.
   WHEN 'EXIT' OR 'CANCEL'.
     LEAVE PROGRAM.
  ENDCASE.



also i have inserted


LOOP AT IT_VBAP.
     CHAIN.
       FIELD WA_VBAP-VBELN.
       FIELD WA_VBAP-POSNR.
       FIELD WA_VBAP-KWMENG.
       FIELD WA_VBAP-NUM.
       FIELD WA_VBAP-TOT1.

       module read_this on CHAIN-REQUEST.



     endchain.
   ENDLOOP.


please try as above

24 REPLIES 24

rajkumarnarasimman
Active Contributor
0 Kudos
2,192

Hi Manish,

It is not required to write the modify command inside the module. Use the below, I hope it will work.


FIELD WA_VBAP-NUM.

FIELD WA_VBAP-TOT1 MODULE CALC.

MODULE CALC INPUT.

WA_VBAP-TOT1 = WA_VBAP-KWMENG + WA_VBAP-NUM.

ENDMODULE.

Regards

Rajkumar Narasimman

0 Kudos
2,192

Hi Rajkumar,

Sorry , your method is yielding the same result.

Regards.

Manish

0 Kudos
2,192

Hi Manish,

Kindly Activate all the objects by clicking the program name at once. 

Also in debug mode, make sure that the value is coming in PAI and PBO.

Last Option, we can update the value in PBO too, that will work.

Regards

Rajkumar Narasimman

0 Kudos
2,192

Hi Rajkumar,

Please refer to the below debugging screenshots:

I have given value 50 in NUM column:

In the debugger, the total is getting added:

This is how the internal table looks like after modification:

But this is how the table control looks due to the subscreen

So the value (50) is getting added, but it is not getting displayed since the table control is inside the subscreen.

Regards

Manish

0 Kudos
2,192

Hi Manish,

Kindly check and write the below code in PBO section in module TC1_GET_LINES,


MODULE TC1_GET_LINES OUTPUT.

"Calculation

IF WA_VBAP-NUM IS NOT INITIAL.

WA_VBAP-TOT1 = WA_VBAP-KWMENG + WA_VBAP-NUM.

ENDIF.

"Describe statement here

DESCRIBE TABLE IT_VBAP LINES L_LINE.

ENDMODULE.

Kindly check in debugger in PBO Section , whether value updating in IT_VBAP.

Regards

Rajkumar Narasimman

0 Kudos
2,192

Hi Rajkumar,

It is already mentioned in Module  TC1_CHANGE_TC_ATTR. I missed out giving its screen shot.

Regards.

Manish.

ipravir
Active Contributor
0 Kudos
2,192

Hi Manish,

You can user SPACE as Sy-UCOMM value for ENTER.

And based on that you can write your logic.

Regards.

Praveer.

0 Kudos
2,192

Hi Praveer

I didnt use any value for sy-ucomm. I dont need to explicitly declare any value for sy-ucomm  in this case. If you check my code in MODULE READ_THIS, if the column NUM is not initial, and then enter is pressed, the total has to be displayed at the right.

Regards.

Manish

ipravir
Active Contributor
0 Kudos
2,192

Hi Manish,

As per your requiement, the calculation should be happen on ENTER Press.

If you debug, you will get SPACE (blank) value on pressing ENTER.

so you could do the calculation.

IF SY-UCOMM EQ SPACE

     calculation logic.

ENDIF.

Regards.

Praveer.

0 Kudos
2,192

Hi Praveer,

I tried what you advised. Still not working

Regards.

Manish

sivaprasad_paruchuri
Active Participant
0 Kudos
2,192

Hi mani ,

Try below statement in chain ,end chain

fieild wa_vbap-num module read_this on input.

regards,

siva

0 Kudos
2,192

Hi Siva,

Its still not working. I did mention that subscreen will not support user commands. So I need to know if I can get the table control in the same screen using a subscreen or by any other way. Since I used a subscreen in this case, no user command will be supported.

Regards.

Manish

0 Kudos
2,192

Hi,

     In Debugger Screen Check for Value of sy-subrc ,

     Probably Sy-subrc is having value 'SUBMIT' , This may be the cause for not getting Modified

      ITab Values.

    

Regards

0 Kudos
2,192

Hi Somendra,

Sy-subrc is zero.

Regards.

Manish

0 Kudos
2,192

Hi Manish,

     Instead of sy_subrc , Check sy-Ucomm

     It's a typo mistake from my end.

     If Sy-Ucomm is having Value 'SUBMIT' then

     Clear Sy-Ucomm Value.

Regards:

Somendra

0 Kudos
2,192

Hi Somendra,

The value of sy-ucomm has nothing to do with the calculation part. Let me remind you that the enter key is not working in this case as the table control is in a subscreen. So my question is, how can I make my table control appear in the same screen after clicking the "SUBMIT" button? Using the table control in a subscreen is not letting the user commands work.

Regards.

Manish

0 Kudos
2,192

Hi,

     Your Itab is updating correctly after enter Key, Again a PBO is called  & In Main Screen

     PBO it is again selecting Value in Itab , Means Itab getting Refreshed.

     Thats Why I asked to Check  for Sy-Ucomm .

Regards

0 Kudos
2,192

Hi,

The value of sy-ucomm is 'SUBMIT'. It is not changing as I havent used sy-ucomm for table control explicitly. Sy-ucomm is used only for the select-options. Even if I clear the value of sy-ucomm, it is not making a difference. Whether sy-ucomm changes or not, the output of the table control has no relevance whatsoever as it is inside the subscreen which is preventing user-command interaction.

Regards.

Manish

Former Member
0 Kudos
2,193

hi manish,

I got the solution for this problem.

what i did is inserted one variable called data_changed (DATA:DATA_CHANGED TYPE N) in

MODULE READ_THIS INPUT.
   IF WA_VBAP IS NOT INITIAL.
     WA_VBAP-TOT1 = WA_VBAP-KWMENG + WA_VBAP-NUM.
     MODIFY IT_VBAP FROM WA_VBAP INDEX TC1-CURRENT_LINE.
     REFRESH CONTROL 'TC1' FROM SCREEN 9002.
     DATA_CHANGED = 1.
   ENDIF.
ENDMODULE.  


when we change value it is changing properly but here in this code it is again generating internal table but with this code it will not allow to again generate internal table due to data_changed value.


MODULE USER_COMMAND_9000 INPUT.
OK_CODE = SY-UCOMM.

CASE OK_CODE.
   WHEN 'SUBMIT'.
   L_DYNPRO = '9002'.

   IF DATA_CHANGED NE '1'.
   SELECT VBELN
          POSNR
          KWMENG
     FROM VBAP
     INTO TABLE IT_VBAP
     WHERE VBELN IN S_VBELN.
     ENDIF.

     CLEAR OK_CODE.
   WHEN 'EXIT' OR 'CANCEL'.
     LEAVE PROGRAM.
  ENDCASE.



also i have inserted


LOOP AT IT_VBAP.
     CHAIN.
       FIELD WA_VBAP-VBELN.
       FIELD WA_VBAP-POSNR.
       FIELD WA_VBAP-KWMENG.
       FIELD WA_VBAP-NUM.
       FIELD WA_VBAP-TOT1.

       module read_this on CHAIN-REQUEST.



     endchain.
   ENDLOOP.


please try as above

0 Kudos
2,192

Hi Abdul,

Your method is working. But I fail to understand the logic behind this method. Why is the internal table getting populated again with the field values after ENTER is pressed. So basically the logic of screen 9000 PAI is getting repeated when I debugged. Why should this happen as the control should not go back to screen 9000's logic.   

Regards.

Manish.

0 Kudos
2,192

hi manish,

PAI will trigger whenever 'ENTER' key is pressed.

0 Kudos
2,192

Hi Abdul,

But it should be the PAI for screen 9002 right? Not PAI of screen 9000.

0 Kudos
2,192

Whenever 'ENTER' is pressed first main screen PAI is triggered and then subscreen PAI will trigger.

vinay4
Newcomer
0 Kudos
2,179

hi guys,

am very new to SAP ABAP can you please tell me that in module pool i have to create 2 subscreens, in subscreen-1: i need to show the data from the MARA table, subscreen-2: i need to show the data from the VBAK table 

then display the data from VBAP in TABLE FORMAT.

here(selection screen fields (material number and sale order number))

can you please tell me how to do it. 😞