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

Capturing Username

Former Member
0 Likes
898

Hi All,

On the user interface screen I have two flags OCflag(1) and Delflag(1), I have Ocfchg(12) and delchg(12) fields for user name who changed the flags. I have to capture the uname who changed the particular flag.

There are only few users who can change. For other users it should not change.

Can someone please help me. I wrote the following code but DELCHG and OCFCHG both are getting uname if only one of it is changed.

CASE SY-UCOMM.

WHEN 'SAVE'.

wa-kunnr = zsdcoop-kunnr.

wa-pfnum = zsdcoop-pfnum.

wa-trnum = zsdcoop-trnum.

wa-coopind = zsdcoop-coopind.

wa-subdate = zsdcoop-subdate.

wa-deldate = zsdcoop-deldate.

wa-reason = zsdcoop-reason.

wa-actdate_from = zsdcoop-actdate_from.

wa-actdate_to = zsdcoop-actdate_to.

wa-cyear = zsdcoop-cyear.

wa-actcode = zsdcoop-actcode.

wa-matnr = zsdcoop-matnr.

IF ( SY-UNAME = 'SANGL' ) OR ( SY-UNAME = 'CHANJ' ) OR ( SY-UNAME = 'HAYESL' ) OR ( SY-UNAME = 'TONIR' ).

wa-delflag = zsdcoop-delflag.

wa-DELCHG = sy-uname.

ENDIF.

IF ( SY-UNAME = 'SANGL' ) OR ( SY-UNAME = 'CHANJ' ) OR ( SY-UNAME = 'HAYESL' ) OR ( SY-UNAME = 'TONIR' ).

wa-ocflag = zsdcoop-ocflag.

wa-OCFCHG = sy-uname.

ENDIF.

MODIFY zsdcoop FROM wa.

Thanks,

Veni.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
876

Do you see any difference in both If statements?

IF ( SY-UNAME = 'SANGL' ) OR ( SY-UNAME = 'CHANJ' ) 
OR ( SY-UNAME = 'HAYESL' ) OR ( SY-UNAME = 'TONIR' ).

Obviously both would satisfied same time.

9 REPLIES 9
Read only

Former Member
0 Likes
877

Do you see any difference in both If statements?

IF ( SY-UNAME = 'SANGL' ) OR ( SY-UNAME = 'CHANJ' ) 
OR ( SY-UNAME = 'HAYESL' ) OR ( SY-UNAME = 'TONIR' ).

Obviously both would satisfied same time.

Read only

0 Likes
876

Hi,

No, but only these users are allowed to change the flag and if one of the user chages a flag then I have to capture that uname and in the chg by name field of that flag. How do I know if a flag is changed.

Thanks,

Veni.

Read only

0 Likes
876

Does these Flags [ (OCflag(1) and Delflag(1) ] changes the value from X or ' ' ?

Check with Debugging.

Read only

0 Likes
876

Hi,

Yes. Initially the flgs will be ' ' and when user wants to cancel that transaction they can put 'X' on the user interface screen and save it. Same for OCflag also.

Thanks,

veni.

Read only

0 Likes
876

You have written the code that way to pass sy-uname only if one is changed . You need to check the value before updating the field.




IF ( SY-UNAME = 'SANGL' ) OR ( SY-UNAME = 'CHANJ' ) OR ( SY-UNAME = 'HAYESL' ) OR ( SY-UNAME = 'TONIR' ). 
if zsdcoop-flag = 'X'.
wa-delflag = zsdcoop-delflag. 
wa-DELCHG = sy-uname. 
endif.
if zsdcoop-ocflag = 'X'.
wa-ocflag = zsdcoop-ocflag. 
wa-OCFCHG = sy-uname. 
endif.

ENDIF. 


Read only

0 Likes
876

>

>How do I know if a flag is changed.

Initially store the values of both flags in some temp variable.

Than the check these flags IF 'X' means user changed the flag.

if flag = 'X'
"Store Sy-uname here in wa.
endif.

Update Ztable now.

In short you must play around these flag values,and do some work around this.

Read only

Former Member
0 Likes
876

Do you think this is a sustainable way to program?

Read only

0 Likes
876

He would Resign Before Auditing, so he need not to worry much.

But atleast he save(As of now) himself by doing the hard-coding the Sy-uname

Read only

0 Likes
876