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

A doubt in parameters

Former Member
0 Likes
1,040

Hi all,

Hope everyone is doing well.I got a small problem.I wrote small SE38 program using parameters to accept few fields and put the data to internal table,then to database from internal table.I need to validate a field(trackid) which is primary key.The validation is for duplication.If the user enter duplicate ID,after F8,a message should be displayed that key already exists and the control should be passed to the trackid field.Previously I have posted the same query in selection screens.Is the same possible when we use parameters option?

Thanks and Cheers.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,018

Try to use below sample coding for updating database table from ur internal table and modify it according to your need...

As your problem is not well cleared..

LOOP AT itab INTO wtab.

SELECT SINGLE * FROM ztable WHERE matnr = wtab-matnr.

IF sy-subrc = 0.

MODIFY ztable FROM wtab.

Elseif sy-subrc <> 0.

insert into ztable value wtab.

ENDIF.

ENDLOOP.

<b>Reward points if it helps you</b>

Thanks & Regards

ilesh 24x7

Hi all,

Hope everyone is doing well.I got a small problem.I wrote small SE38 program using parameters to accept few fields and put the data to internal table,then to database from internal table.I need to validate a field(trackid) which is primary key.The validation is for duplication.If the user enter duplicate ID,after F8,a message should be displayed that key already exists and the control should be passed to the trackid field.Previously I have posted the same query in selection screens.Is the same possible when we use parameters option?

Thanks and Cheers.

7 REPLIES 7
Read only

Former Member
0 Likes
1,018

Yes, it is possible.

If user enters Track ID value in parameter P_TRACKID in selection screen, you can use event AT SELECTION_SCREEN ON P_TRACKID, to validate if the entry exists in the table. If it exists, you can display error message,

Hope this helps.

ashish

Read only

Former Member
0 Likes
1,018

Hi,

yes the same thing is possible in parameters also..

If you want to validate after F8 is pressed.do the validation in the START-OF-SELECTION event or else normally you can do by

AT SELECTION_SCREEN ON P_TRACKID

REgards

Sheron

Read only

Former Member
0 Likes
1,018

it is possible...

use AT SELECTION-SCREEN.

this are various form of AT SELECTION-SCREEN

AT SELECTION-SCREEN OUTPUT.

for providing F4 help...

<b>AT SELECTION-SCREEN ON VALUE-REQUEST</b>.

For Validating your select-option..

<b>AT SELECTION-SCREEN ON FIELD or ON BLOCK.</b>

eg..

AT SELECTION-SCREEN ON S_TRID.

where S_TRID is the Select-option u declared before..

AT SELECTION-SCREEN.

Thanks & Regards

ilesh 24x7

Read only

0 Likes
1,018

Thanks for your replies.Its working,but my concern is when I press <enter> only,the code validates and message is displayed but not when tab is pressed,Is it possible to validate code when tab is pressed,something like lost focus.Here is my code

tables zgtable.

parameters:trackid(10) type n,

artist(25) type c.

types:begin of warea,

mandt type zgtable-mandt,

trackid type zgtable-trackid,

artist type zgtable-artist,

end of warea.

data:itable type standard table of warea with header line.

move trackid to itable-trackid.

move artist to itable-artist.

append itable.

at selection-screen on trackid.

select * from zgtable where trackid = trackid.

endselect.

if sy-dbcnt <> 0.

message i000.

endif.

insert zgtable from table itable.

Few more problems:

1)data is not getting stored in table when we enter correct trackid,why?

and if i use 'at selection-screen on VALUE-REQUEST' following error is coming

'value-request is neither a selection criterion nor a parameter'...why?

Thanks

Read only

0 Likes
1,018

tables zgtable.

parameters:trackid(10) type n,

artist(25) type c.

types:begin of warea,

mandt type zgtable-mandt,

trackid type zgtable-trackid,

artist type zgtable-artist,

end of warea.

data:itable type standard table of warea with header line.

move trackid to itable-trackid.

move artist to itable-artist.

append itable.

data : itgtable type standard table of zgtable with header line.

at selection-screen on trackid.

Try to use internal tables always where it is possible..

<b>select * from zgtable into table itgtable where trackid = trackid.

if sy-subrc <> 0.</b>

message i000.

endif.

<b>insert zgtable from table itable.</b>

<b>Try to debug and see the flow of program...

are the values are getting updated or not ?</b>

<i><b>Reward points if for all usefull answers</b></i>

Thanks & Regards

ilesh 24x7

Read only

0 Likes
1,018

I got your 1st point which says that we can use internal tables the way you used.Secondly I really dont know how to debug a program.After I run the program, I check the database where I dont find the values.

Thanks

Read only

Former Member
0 Likes
1,019

Try to use below sample coding for updating database table from ur internal table and modify it according to your need...

As your problem is not well cleared..

LOOP AT itab INTO wtab.

SELECT SINGLE * FROM ztable WHERE matnr = wtab-matnr.

IF sy-subrc = 0.

MODIFY ztable FROM wtab.

Elseif sy-subrc <> 0.

insert into ztable value wtab.

ENDIF.

ENDLOOP.

<b>Reward points if it helps you</b>

Thanks & Regards

ilesh 24x7