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

dialog program

Former Member
0 Likes
2,237

Hi,

I am working on a module pool program.I have created ascreen 2000 in which there are many fields taken from mvke,mara and marc.If the user wants to change values of some fields in the o/p in this screen,then he can change the values using the dropdown list and when he clicks on the chechbox besides that field,then the changed value should get stored in that particular table from where the field is taken.

How can i capture only checked fields and how can i store the

changed values in the table?

Can anyone help me solve this problem.Its very urgent!!

Regards,

Radha

24 REPLIES 24
Read only

Former Member
0 Likes
2,194

Hi Radha,

Once the user changes the values just check them against the values in table ,

if not same then using update Query update that entry in table.

Regards,

Vaibhav Modi.

******Reward Useful Replies.

Read only

0 Likes
2,194

Can we use set parameter id for updating the changed values in the table

Read only

0 Likes
2,194

set parameter id will store the value entered in the screen in sap memory .it will not update the database table automatically.

Read only

0 Likes
2,194

Hi Radha,

U just use CASE statement or IF statements......

IF check1 = 'x'.

Update table tablename ......where fieldname = dd1.

dd1 is the dropdown list variable.

dd1 holds the value the user has changed.

I think this will work.....

Dont forget to reward points if useful.

Pavan.

Read only

0 Likes
2,194

Hi,

How can I assign a value to drop down list in the attribute window of the screen painter?

Read only

0 Likes
2,194

to assign values in the drop down list.

u have to code in main program.

use type pools vrm.

copy this into a report program.and debug.

u will get an idea.

PARAMETERS P_PLANT TYPE STR AS LISTBOX VISIBLE LENGTH 10.

TYPE-POOLS: VRM.

DATA: T_PLANT type vrm_values.

INITIALIZATION.

APPEND '1000' TO T_PLANT.

APPEND '3200' TO T_PLANT.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'P_PLANT'

values = T_PLANT.

Read only

0 Likes
2,194

Hi Kamini,

The values in the droplist are automatically coming in the o/p.

My doubt is,How can we know only the checked field and only the changed value will get updated in the database?

Read only

0 Likes
2,194

Hi,

see suppose in ur screen :

field1 ________ |_| checkbox1.

field2 ________ |_| checkbox2.

in main program.

when u write

if checkbox1 = 'X'.

update <dbtab> set <field > = field1.

endif.

.

.

.

similarly for other fields.

"this statement will update the database table field with the value in field1. if checkbox1 is ticked.

whenever user checks the box the variable for checkbox (here checkbox1) will store the value X.

hope i made this clear.

Read only

0 Likes
2,194

Hi,

Now the values are getting updated into the table.But if i check 2 or checkboxes and click on the execute button all the changed values should get updated into tables.But this is not happening.Only the first checked field value is getting uploaded into table.

Read only

0 Likes
2,194

do like this

if c1 = 'X'.

update....

endif.

if c2 = 'X'.

update..

endif.

if u have included update statements in if....elseif...endif.

statements then it will execute only the first true condition.

Read only

0 Likes
2,194

Hi,

Now the values are getting updated into the table.But if i check 2 or 3 checkboxes and click on the execute button all the changed values in all the checked fields should get updated into tables.But this is not happening.Only the first checked field value is getting uploaded into table.

Read only

0 Likes
2,194

hi,

i think u have coded the full logic for all checkboxes in one if else.

u should have separate if for all checkboxes.

if c1 = 'X'.

text = 'check1'.

endif.

if c2 = 'X'.

text = 'check2'.

endif.

if c3 = 'X'.

text = 'check3'.

endif.

i executed a sample program for this and it was working fine.

u try debugging ur code and put a breakpoint where u are checking the values of checkboxes.

and see if the value of the check box is X then is it going inside that if stament or not.

i hope u understood the concept.

Regards,

Kamini

Read only

0 Likes
2,194

Hi Kamini,

Thank you very much.

Now all the field values changed in the update screen and which are checked are getting updated in the database table.

But actually there is an o/p screen in which there are many records.If the user wants to change the values of a particular record,then he clicks on the checkbox placed besides that record and clicks on the execute button.Then the control goes to the update screen2000.

Here the changed values are getting updated in the database table.But the values are getting updated in all the records along with the record selected in the o/p screen.This should not happen.Only the selected record should get updated with the changed value.

How can this happen?

Read only

0 Likes
2,194

Dear Radha,

apply the same logic to retrieve the selected record from the previous screen.

Also in ur update statement add a where condition so that only the record which specifies the condition gets updated.

update <dbtab> set <field> = <value>

where.......

i hope now your problem is solved

Regards,

Kamini

Read only

0 Likes
2,194

Hi,

To retrieve the record from the previous screen I have used this logic.

READ TABLE gt_output INTO gs_output1 index ls_selfield-tabindex.

IF sy-subrc = 0.

CALL SCREEN 2000.

ENDIF.

But how can I use this logic in this screen?

Read only

0 Likes
2,194

now.

in the pai of screen 2000.

if c1 = 'X'.

update <dbtab> set <field> = <value>

where <field1 > = gs_output1-<field1>

and <field2> = gs_output1-<field2>

....

..so on include all those fields which will uniquely identify that record.

i mean primary key feilds of ur database table.

now only that record will be updated.

hope now u r satisfied with my answers

Read only

0 Likes
2,194

Hi Kamini,

This is not working.

I have written the update statement like this.

Please check it.

CASE OK_CODE.

WHEN 'EXECUTE'.

IF DCHAIN = c_x.

UPDATE mvke SET vmsta = gs_output1-vmsta

WHERE vmsta = gs_output1-vmsta.

ENDIF.

Read only

0 Likes
2,194

Hi,

UPDATE mvke SET vmsta = gs_output1-vmsta

WHERE vmsta = gs_output1-vmsta.

this is not going to work.

as u are changing the record with same value.

i mean in the set and where clause the value u are using (gs_output1-vmsta) which is same .so how is it going to change?

see if there is record say

a b c d

a12 b12 c12 d12 .

now if u want to change some value in it u have to identify that record (by using primary keys).

suppose here a and b are primary keys.

and u want to change value of a and c here .

then ur update statement should be like this :

update <dbtab> set : a= a13

c = c14

where a = a12 and b= b12.

what u have done is :

update <dbtab> set a = a12

where a = a12.

how is it going to change?

for table mvke the primary keys are :

MATNR

VKORG

VTWEG

use these to identify the record.

i hope u got my point.

regards,

Kamini

Read only

Former Member
0 Likes
2,194

hi,

in ur top include give the sanme name to the check box as u have given in screen.

suppose ur check box name in screen is c1 for matnr from mara.

and u have named i/o field as fmatnr in screen.

then in ur top include.

data c1 type c,

fmatnr type mara-matnr.

in ur main program.

in pai module.

if c1 = 'X'.

then update ur database table.

update mara set matnr = fmatnr.

like this u can code for other fields also.

hope it is clear now.

Read only

0 Likes
2,194

Hi Kamini,

I have declared all my checkboxes in my top include.

For example: I have given one of my checkbox name as DCHAIN_SPEC in the attributes window for screen 2000.

I have declared this as

Data: DCHAIN_SPEC TYPE C.

I am getting error as 'Field DCHAIN_SPEC is not defined.It is neither specified in one of the tables nor defined by a data statement'.

What would be the reason for this?

Regards,

Radha

Read only

0 Likes
2,194

did u activate ur top include?

may be u have declared and saved .

and as u did not activate the top include ,it will give error when u perform syntax check on ur main program.

Read only

0 Likes
2,194

hI,

There is no seperate top include.All the declaration is done in the main program itself.I have activated it.But still it is giving error

Read only

Former Member
0 Likes
2,194

Hi,

From your screen program

PROCESS AFTER INPUT.

*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TC_B'

LOOP AT T_DISP.

CHAIN.

FIELD WA_DISP-CHKBOX MODULE CHKBOX.

  • FIELD WA_DISP-SNO.

  • FIELD WA_DISP-NAME.

  • FIELD WA_DISP-SELNM.

  • FIELD WA_DISP-PRICE.

  • FIELD WA_DISP-CONDN.

endchain.

ENDLOOP.

&----


*& Module CHKBOX INPUT

&----


  • text

----


MODULE CHKBOX INPUT.

MOVE-CORRESPONDING TC_B TO WA_DISP.

MODIFY T_DISP FROM WA_DISP INDEX TC_B-CURRENT_LINE.

READ TABLE T_DISP INTO WA_DISP WITH KEY CHKBOX = C_X. " index TC_B-CURRENT_LINE.

ENDMODULE. " CHKBOX INPUT

Then read the internal table

LOOP AT T_DISP INTO WA_DISP WHERE CHKBOX EQ C_X.

MODIFY ****************

ENDLOOP.

If it solve ur problem , Please award points.

Read only

Former Member
0 Likes
2,194

Set Parameter ID will store the values in the SAP memory and not in the ABAP memory. Please correct me if I am wrong.

Now if you are trying to update the databse tables you can use the statement such as UPDATE or MODIFY.