Using Exec_Os400 command in V13

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
pravik
Posts: 60
Joined: Tue Dec 26, 2017 6:44 pm

Using Exec_Os400 command in V13

Post by pravik » Tue Mar 05, 2019 3:37 pm

Hi All,

I wanted to use "Exec_Os400" to execute some OS400 commands in V13 of lansa using WAM, during compilation its shows warning message its not support and would give run time error. Checkin gets completed successfully, and when i try to execute from URL it doesnt give error message nor log gets generated, but commands doesnt gets execute since we dont get expected output.

Can you please help us how do we use this command or some alternate solution to execute OS400 commands.

Thanks for your help in-advance.

Thanks,
Priya

soa
Posts: 302
Joined: Mon Dec 07, 2015 3:15 pm

Re: Using Exec_Os400 command in V13

Post by soa » Tue Mar 05, 2019 4:15 pm

If you can't call it from the WAM you could probably put the Exec_OS400 in an RDML function and then call that.

MarkD
Posts: 627
Joined: Wed Dec 02, 2015 9:56 am

Re: Using Exec_Os400 command in V13

Post by MarkD » Tue Mar 05, 2019 4:23 pm

Note comment about using the SYSTEM_COMMAND built- in function in https://docs.lansa.com/14/en/lansa015/i ... _os400.htm
Maybe that will work in a WAM.

MarkDale
Posts: 103
Joined: Wed Dec 02, 2015 10:06 am

Re: Using Exec_Os400 command in V13

Post by MarkDale » Tue Mar 05, 2019 5:06 pm

It worked for me. I'm using a V14SP2 environment, but I think it would be the same.

My wam looked like this:

Code: Select all

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_WAM)

* Map fields used in this form.

Web_Map For(*BOTH) Fields(#STD_TEXT)

Webroutine Name(UHandleEvent)

Change Field(#std_text) To('Fred')

Exec_Os400 Command('CHGDTAARA DTAARA(VF24DEMLIB/ABCTEST (1 5)) VALUE(END2) ')

Endroutine

End_Com
I checked it in to the IBMi and and compiled it

I ran the web routine using the url against the IBMi like this:

http://server:port/cgi-bin/lansaweb?wam=TST_X620&webrtn=UHandleEvent&ml=LANSA:XHTML&part=DEM&lang=ENG

And the data area was updated to END2.

So I think it is possible

pravik
Posts: 60
Joined: Tue Dec 26, 2017 6:44 pm

Re: Using Exec_Os400 command in V13

Post by pravik » Tue Mar 05, 2019 5:09 pm

Hi MarkDale,

Even we had used in V14Sp2 but i wanted to use in V13Sp2 in WAM component.

As Mark had suggested trying to use SYSTEM_COMMAND builtin.

Thanks,
Priya

pravik
Posts: 60
Joined: Tue Dec 26, 2017 6:44 pm

Re: Using Exec_Os400 command in V13

Post by pravik » Tue Mar 05, 2019 5:49 pm

Hi Mark,

I tried using SYSTEM_COMMAND but using this command im not able to pass values dynamicly

when i tried below command it worked as expected

Use Builtin(SYSTEM_COMMAND) With_Args('X' '(CHGUSRPRF USRPRF(PRIYAD) STATUS(*DISABLED))') To_Get(#STD_NUM)

whereas if pass the value it doesn't work as expected

Use Builtin(SYSTEM_COMMAND) With_Args('X' '(CHGUSRPRF USRPRF(#LDUSER1) STATUS(*DISABLED))') To_Get(#STD_NUM)

Do we have some alternate for this

Thanks,
Priya

MarkD
Posts: 627
Joined: Wed Dec 02, 2015 9:56 am

Re: Using Exec_Os400 command in V13

Post by MarkD » Wed Mar 06, 2019 9:00 am

#LDUSER1 is a LANSA variable?

Wouldn't you have to use something like '(CHGUSRPRF USRPRF(' + #LDUSER1 + ') STATUS(*DISABLED))' to form the correct command string?

I think the EXEC_OS400 command will handle substitution variables automatically, but SYSTEM_COMMAND does not.

Alternatively, sometimes ( '(CHGUSRPRF USRPRF(&1) STATUS(*DISABLED))' ).subsitute(#LDUSER1) could be used I guess.

pravik
Posts: 60
Joined: Tue Dec 26, 2017 6:44 pm

Re: Using Exec_Os400 command in V13

Post by pravik » Wed Mar 06, 2019 6:06 pm

Hi Mark,

i tried both the solutions ans its not working.

Thanks,
Priya

User avatar
lawingo
Posts: 51
Joined: Fri Dec 04, 2015 6:41 am

Re: Using Exec_Os400 command in V13

Post by lawingo » Wed Mar 06, 2019 11:57 pm

We build our string first and execute the AS400 command from a server function instead of embedding the string in the arguments:
This code is used for sending an email. It works great!

Code: Select all

#W_CMD := 'SNDSMTPEMM RCP((' + #EMAILTO + ')) SUBJECT(' + "'" + #emailsbj + "'" + ') NOTE(' + "'" + #emailmsg + "'" + ') ATTACH((' + "'" + #EMAILRTNM + "'" + ' *PDF))'
Exchange Fields(#W_CMD)
Use Builtin(CALL_SERVER_FUNCTION) With_Args(*SSERVER_SSN SHAPSVM Y Y) To_Get(#FW_RETCD)
and the server function (SHAPSVM) code looks like this:

Code: Select all

Use Builtin(SYSTEM_COMMAND) With_Args('X' #W_CMD) To_Get(#SH_SQ)

MarkD
Posts: 627
Joined: Wed Dec 02, 2015 9:56 am

Re: Using Exec_Os400 command in V13

Post by MarkD » Thu Mar 07, 2019 8:28 am

The L4Web job must be producing a QPJOBLOG job log file.
Look in it, or look at the active jobs job log, for error messages.
eg: Maybe the L4Web job user is not authorized to the CHGUSRPRF command, or authorized to change the profile of whatever name is in variable #LD_USER1 or maybe the command string you have formed is not syntactically correct - maybe it has a leading bracket or missing bracket or something like that.

MarkD
Posts: 627
Joined: Wed Dec 02, 2015 9:56 am

Re: Using Exec_Os400 command in V13

Post by MarkD » Thu Mar 07, 2019 8:34 am

You could also try defining a command string:

Define #CommandtoExecute *char 256

#CommandToExecute := "CHGUSRPRF USRPRF(" + #LDUSER1 + ") STATUS(*DISABLED)"'

Message msgtxt("Executing ======> " + #CommandtoExecute)

Use Builtin(SYSTEM_COMMAND) With_Args('X' #CommandToExecute) To_Get(#STD_NUM)

Then look at the L4Web job's job log to see the MESSAGE isssued which should show exactly what command you are executing and any associated error messages.

pravik
Posts: 60
Joined: Tue Dec 26, 2017 6:44 pm

Re: Using Exec_Os400 command in V13

Post by pravik » Thu Mar 07, 2019 10:46 pm

Hi Mark,

I tried using the command as you specified but yet no luck favored. We have sufficient authority to execute this command.

Userprofile value when its been hard coded command gets executed as expected but if we pass as parameter then it fails and in log we get below shown error message.

"Error found on *N command"

WAM Code executed:
Define Field(#ENCMD) Type(*CHAR) Length(256)
#USER001 := PRIYAD
#ENCMD := 'CHGUSRPRF USRPRF("+ #USER001 +") STATUS(DISABLED)'
Message Msgtxt("Executing ======> " + #ENCMD)

Use Builtin(SYSTEM_COMMAND) With_Args('X' #ENCMD) To_Get(#STD_NUM)

Thanks,
Priya

atostaine
Posts: 414
Joined: Wed Jan 20, 2016 7:38 am

Re: Using Exec_Os400 command in V13

Post by atostaine » Fri Mar 08, 2019 12:47 am

Do you have disabled or *DISABLED?

Sometimes when you build command strings things can get messed up. Can you show the joblog?
Art Tostaine

MarkD
Posts: 627
Joined: Wed Dec 02, 2015 9:56 am

Re: Using Exec_Os400 command in V13

Post by MarkD » Fri Mar 08, 2019 9:22 am

Good point Art - trying that from command entry yields this type of error:
Capture.PNG
Capture.PNG (5.49 KiB) Viewed 6356 times
I'd search the job log for an error message like that.

MarkD
Posts: 627
Joined: Wed Dec 02, 2015 9:56 am

Re: Using Exec_Os400 command in V13

Post by MarkD » Fri Mar 08, 2019 9:26 am

Even when you get the syntax right there's other errors that can be encountered, for example:
Capture.PNG
Capture.PNG (4.27 KiB) Viewed 6356 times
So I'd make sure I could read the job log fully to see either an error or a message saying the user profile was changed.

Post Reply