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

Codings in Maintenance View - Status ?

0 Likes
1,525

Hi ... I am in a dilemma now.

I try to trap the value before saving my data.

So, I code in the maintenance view.

It is a very simple process but I just can't figure how to get it work.

Let's say, ... I have 4 columns in a table.

Key1, Field1, Field2, Field3.

Existing Data ( 3 records here )

key1, f1, f2, f3

key2, f4, f5, f6

key3, f7, f8, f9

Apart from the key, I need to make sure that the Field1, Field2, Field3 is unique.

So, before I save the data, I will perform a COUNT via SQL.

My problem is, it loops through all the record.

Can I have a status like, only fields / record that updated go through the validation ?

Any system variable in SAP that allow me to check whether it is UPDATE / INSERT status ?

Thanks.

PROCESS AFTER INPUT.

MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.

MODULE LISTE_BEFORE_LOOP.

LOOP AT EXTRACT.

MODULE LISTE_INIT_WORKAREA.

CHAIN.

// .... all the codes here

MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.

ENDCHAIN.

FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.

CHAIN.

FIELD ZTMPU_GEN_MATMAS-MATNR .

MODULE LISTE_UPDATE_LISTE.

ENDCHAIN.

ENDLOOP.

Hi ... I am in a dilemma now.

I try to trap the value before saving my data.

So, I code in the maintenance view.

It is a very simple process but I just can't figure how to get it work.

Let's say, ... I have 4 columns in a table.

Key1, Field1, Field2, Field3.

Existing Data ( 3 records here )

key1, f1, f2, f3

key2, f4, f5, f6

key3, f7, f8, f9

Apart from the key, I need to make sure that the Field1, Field2, Field3 is unique.

So, before I save the data, I will perform a COUNT via SQL.

My problem is, it loops through all the record.

Can I have a status like, only fields / record that updated go through the validation ?

Any system variable in SAP that allow me to check whether it is UPDATE / INSERT status ?

Thanks.

PROCESS AFTER INPUT.

MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.

MODULE LISTE_BEFORE_LOOP.

LOOP AT EXTRACT.

MODULE LISTE_INIT_WORKAREA.

CHAIN.

// .... all the codes here

MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.

ENDCHAIN.

FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.

CHAIN.

FIELD ZTMPU_GEN_MATMAS-MATNR .

MODULE LISTE_UPDATE_LISTE.

ENDCHAIN.

ENDLOOP.

11 REPLIES 11
Read only

sridhar_meesala
Active Contributor
0 Likes
1,493

Hi,

If I understood your question, you want to validate the fields f1, f2, f3 after modifications whether they are unique or not. If it is correct then why don't you make the 3 fields as key fields so that autometically they will be checked for duplicate entries.

I hope I understood your question. Ignore if I misunderstood.

Thanks,

Sri.

Read only

0 Likes
1,492

I can't ... because key can't be modified and to simplify my example i only put 3 fields.

actual fact, i have over 10 fields.

Read only

0 Likes
1,492

hello,

for checking whether its unique ... just use it as primary key fields...

try to use table maintenance events for this purpose.

check events

05 Creating a new entry

08 After correcting the contents of a selected field

18 After checking whether the data has changed

use a variable to hold the count and do the anomalies

Edited by: Keshu Thekkillam on Aug 5, 2009 12:55 PM

Read only

0 Likes
1,492

Yeah, I am trying the event as well but how can I reference the variable that I am currently modifying ?

Sorry, I am a real newbie and started development less than 3 months.

Read only

0 Likes
1,492

Hi,

When you use an event you create an entry for the same in the events and add the subroutine and the program where you are goign to have that subroutine then in then on the right hand side you would get an icon where you can click to navigate to the subroutine in the subroutine you can access the strucutre of the table where you are saving the records and also structures : TOTAL and EXTRACT after you create an entry for the event just put a break-point in the code and check for the structures of the table name and TOTAL and EXTRACT and STATUS.

Regards,

Himanshu

Read only

Former Member
0 Likes
1,492

Hi,

You can use table maintenence events.

For this go to,

1.table maintenence generator->environment->modification-> events

2.In that use different evetns like event number 05 creating a new entry or 26 before making list.

3. And in the routine u can handle validation part.

4. In the routine you will get fields/record. So validation wil be easier.

You can handle field value by syntax 'tab_name-field_name'.

Read only

0 Likes
1,492

In your case you can use event number 26 and refer variable directly as tablename-fieldname.

This event will be triggered for each record u r modifying or updating.

Read only

0 Likes
1,492

Thanks again ...

I will try it out.

If I have 2 maintenance screen, the first one will show all the listing and the second one is only 1 record.

How can I disable edit in first screen ?

I can't find any options there ...

Should I modify PAI , MODULE LISTE_UPDATE_LISTE. ?

Read only

0 Likes
1,492

i hope you are using a maintenenace view.

in view field tab...make the fouth field as 'R' for read only field option

Edited by: Keshu Thekkillam on Aug 5, 2009 2:11 PM

Read only

0 Likes
1,492

Hi,

In order to disable other fields you can create another module in PBO and add teh code like below:


Loop at screen.
 if screen-name = 'F1'.
 screen-input = 0.
modify screen.
endif.
endloop.

Regards,

Himanshu

Read only

0 Likes
1,492

Something strange ...

I coded the subroutine under event - 05 , inserting new record.

When I SAVE it, the record created.

But, when I exit, the message prompted.

It seems like the validation didn't fire.

Maybe I use the wrong message.

IF var_total > 1.

message e250(zmm) with 'The criterias you entered already exist'.

ENDIF.

Any ideas ? Thanks.