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: 

Table control field change indicator

Former Member

Hello..

Let's say we have the following code in the PAI for a table control having filed f1.

FIELD f1 MODULE mod1 ON REQUEST.

Is there any way to trigger this module mod1 even though it's value is not changed? Is there any change indicator that we can set programatically?

Actually my requirement is to upload some records into the table control from a text file. After that the usual validations should take place on the table control. In this case the table control won't trigger the modules ON REQUEST. Is there any way to force this?

Thanks very much.

6 REPLIES 6

Former Member
0 Kudos

Hello Abhi,

The statement

 FIELD <f> MODULE <m> ON REQUEST 

is a conditional module call - it gets executed when the contents of the field <f> have been altered.

That said, you could actually choose to omit this addition. For example:


MODULE COMPARE INPUT.
* 1. determine the current line in the table control as per the program
* 2. compare the above line with the value I_ITAB.
* 3. If there's a difference in step 2, then the line was changed.
ENDMODULE.

PROCESS AFTER INPUT.
  LOOP AT I_ITAB.
    MODULE COMPARE.
  ENDLOOP.

Please note that the internal table I_ITAB is the same in the program and in the screen. And that it has a header line.

Now regarding the actual requirement, I have a few doubts.

1. Are you uploading the file on the same screen as the table control?

2. Does the table control have any editable fields?

3. What is the puepose of the table control ? (are you using it only because you want some validations to be done automatically ?)

Regards,

Anand Mandalika.

ssimsekler
Active Contributor
0 Kudos

Hi Abhi

As Anand mentioned in his post, <b>"ON REQUEST"</b> addition is optional. <b>"FIELD"</b> statement is used for making the screen field content transfered to the program variable. You can use <b>"ON REQUEST"</b> addition to trigger the transfer if the field value is changed. The addition <b>"ON VALUE"</b> is used to transfer the field value in case the field contains some value (i.e. not space).

For multiple field transfer, to bind multiple fields to a module, you can use <b>"CHAIN"</b> statement.

<u><b>e.g.</b></u>


CHAIN .
FIELD gs_wa-field_1 .
FIELD gs_wa-field_2 .
...
FIELD gs_wa-field_n .

MODULE module_1 
       [ON CHAIN-REQUEST / ON CHAIN-VALUE] .
...
MODULE module_n 
       [ON CHAIN-REQUEST / ON CHAIN-VALUE] .

ENDCHAIN . 

In fact, these are dialog(screen) programming basics. So you can refer to the standard SAP course <b>BC410 (this is the old code, maybe changed) - Dialog Programming</b>.

*--Serdar

0 Kudos

Hello Serdar / Abhi,

Just like to make a small correction.

In screen flow logic, there's <b>no</b> addition called <b>ON VALUE</b>. What you are referring to here is the <u><b>ON INPUT</b></u> addition.


FIELD <f> MODULE <m> ON INPUT.

or
CHAIN.
  FIELD: <f1>, <f 2>,... 
  MODULE <mod1> ON CHAIN-INPUT|CHAIN-REQUEST.
  FIELD: <g1>, <g 2>,... 
  MODULE <mod2> ON CHAIN-INPUT|CHAIN-REQUEST.
 ...
ENDCHAIN. 

Regards,

Anand Mandalika.

Former Member
0 Kudos

Thanks very much for the info guys. What I exactly need is,I want the module to be fired only when changes are made to the field (ON REQUEST).

But I also want to know is there a way we can fire this module even though the value was not changed? (Like in my case new rows are uploaded from text file into the table control internal table)

From the text file i upload the contents directly to the (editable)table control internal table. So after the internal table is filled, in the next PBO the uploaded contents are shown in the table control. SO, Now I need to fire all the ON REQUEST modules for the newly uploaded rows so that validations occur.

Hope u understood my problem.

0 Kudos

Hi,

If your program is structured in a way that in every module, you are calling a form to perform a certain task, then you can call the same forms right after you upload data from file. Its like:


//Your flow logic
CHAIN.
  FIELD: <f1>, <f 2>,... 
  MODULE <mod1> ON CHAIN-INPUT|CHAIN-REQUEST.
  FIELD: <g1>, <g 2>,... 
  MODULE <mod2> ON CHAIN-INPUT|CHAIN-REQUEST.
 ...
ENDCHAIN

//Your program logic
MODULE <mod1> INPUT
 PERFORM <form1>.
ENDMODULE

MODULE <mod2> INPUT
 PERFORM <form2>.
ENDMODULE

So you can call <form1>, <form2>,... directly for the validations. Another way, I am not sure if it will work, need to try it out, is to check the value of system variable sy-datar. If I can recall it correctly, its value is set to 'X' as soon as a screen field is changed. As I said, I am not sure if it would work in this case as well.

Hope it helps.

Regards

raghu1991
Discoverer
0 Kudos

Hi,

if the issue was resolved, Could you please share your solution.

Thanks.