Page 1 of 1

Using Exec_Os400 command in V13

Posted: Tue Mar 05, 2019 3:37 pm
by pravik
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

Re: Using Exec_Os400 command in V13

Posted: Tue Mar 05, 2019 4:15 pm
by soa
If you can't call it from the WAM you could probably put the Exec_OS400 in an RDML function and then call that.

Re: Using Exec_Os400 command in V13

Posted: Tue Mar 05, 2019 4:23 pm
by MarkD
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.

Re: Using Exec_Os400 command in V13

Posted: Tue Mar 05, 2019 5:06 pm
by MarkDale
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

Re: Using Exec_Os400 command in V13

Posted: Tue Mar 05, 2019 5:09 pm
by pravik
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

Re: Using Exec_Os400 command in V13

Posted: Tue Mar 05, 2019 5:49 pm
by pravik
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

Re: Using Exec_Os400 command in V13

Posted: Wed Mar 06, 2019 9:00 am
by MarkD
#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.

Re: Using Exec_Os400 command in V13

Posted: Wed Mar 06, 2019 6:06 pm
by pravik
Hi Mark,

i tried both the solutions ans its not working.

Thanks,
Priya

Re: Using Exec_Os400 command in V13

Posted: Wed Mar 06, 2019 11:57 pm
by lawingo
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)

Re: Using Exec_Os400 command in V13

Posted: Thu Mar 07, 2019 8:28 am
by MarkD
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.

Re: Using Exec_Os400 command in V13

Posted: Thu Mar 07, 2019 8:34 am
by MarkD
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.

Re: Using Exec_Os400 command in V13

Posted: Thu Mar 07, 2019 10:46 pm
by pravik
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

Re: Using Exec_Os400 command in V13

Posted: Fri Mar 08, 2019 12:47 am
by atostaine
Do you have disabled or *DISABLED?

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

Re: Using Exec_Os400 command in V13

Posted: Fri Mar 08, 2019 9:22 am
by MarkD
Good point Art - trying that from command entry yields this type of error:
Capture.PNG
Capture.PNG (5.49 KiB) Viewed 7906 times
I'd search the job log for an error message like that.

Re: Using Exec_Os400 command in V13

Posted: Fri Mar 08, 2019 9:26 am
by MarkD
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 7906 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.