Cobol calling Shell Script

 3 Replies
 1 Subscribed to this topic
 17 Subscribed to this forum
Sort:
Author
Messages
klkemp100
Basic Member Send Private Message
Posts: 14
Basic Member

Has anyone created or modified a Lawson Cobol program to call a UNIX Shell script, and if so can you share how you accomplished this?

Thanks!

LauraPat
Veteran Member Send Private Message
Posts: 50
Veteran Member
Here is an example of a custom Cobol program we have which calls a script - obviously, there are several fields set up in the WS portion of the custom program - but I think you get the gist:

* string together the absolute pathnames of the perl script *
* used to make sure a CRLF ends each message block and the *
* output file created by this program. The script will make *
* sure the file is formatted properly for healthcare standards. *
*********************************************************************

J80615 IF (ICLAWDWS-UNIX)
151461 STRING BI523WS-PERL-COMMAND DELIMITED BY SIZE
151461 BI523WS-SLASH-MARK DELIMITED BY SIZE
151461 ICLAWDWS-LAWDIR-NAME DELIMITED BY SPACE
151461 BI523WS-SLASH-MARK DELIMITED BY SIZE
151461 CASEWS-INPUT-VALUE DELIMITED BY SPACE
151461 BI523WS-SLASH-MARK DELIMITED BY SIZE
151461 "icsrc" DELIMITED BY SIZE
151461 BI523WS-SLASH-MARK DELIMITED BY SIZE
151461 "icperllfcr.pl " DELIMITED BY SIZE
151461 WS-HC-DIR-FILENAME DELIMITED BY " "
151461 INTO BI523WS-PERL-STRING
J80615 ELSE
J80615 STRING BI523WS-PERL-COMMAND DELIMITED BY SIZE
J80615 ICLAWDWS-LAWDIR DELIMITED BY SPACE
J80615 BI523WS-BACKSLASH-MARK DELIMITED BY SIZE
J80615 CASEWS-INPUT-VALUE DELIMITED BY SPACE
J80615 BI523WS-BACKSLASH-MARK DELIMITED BY SIZE
J80615 "icsrc" DELIMITED BY SIZE
J80615 BI523WS-BACKSLASH-MARK DELIMITED BY SIZE
J80615 "icperllfcr.pl " DELIMITED BY SIZE
J80615 WS-HC-DIR-FILENAME DELIMITED BY " "
J80615 INTO BI523WS-PERL-STRING
J80615 END-IF.

VER004 MOVE SPACES TO BI523WS-PERL-STRING.
VER004 STRING "/opt/app/lsftest/law/target/script/BI523perl"
VER004 " " DELIMITED BY SIZE
VER004 WS-HC-DIR-FILENAME DELIMITED BY SPACE
VER004 " " DELIMITED BY SPACE
VER004 WS-NULL-CHAR DELIMITED BY SIZE
VER004 INTO BI523WS-PERL-STRING.
VER004
VER004 DISPLAY BI523WS-PERL-STRING.

151461 CALL "SYSTEM" USING BI523WS-PERL-STRING.
John Henley
Send Private Message
Posts: 3351

There are other examples, including some delivered with Lawson itself, such as IMDBB. The key in my experience is don't forget the command string must be null-terminated .

Thanks for using the LawsonGuru.com forums!
John
Greg Moeller
Veteran Member Send Private Message
Posts: 1498
Veteran Member
I usually just create a new program. All that's really needed if your script is doing all of the real work is the following:
In the WS file
01 GH070WS.
02 WS-CONVERT-SCRIPT PIC X(50).
In the PD file
000100******************************************************************
000200 050-EDIT-PARAMETERS SECTION 10.
000300******************************************************************
000400 050-START.
000500
000600 050-END.
000700
000800******************************************************************
000900 100-PROGRAM-CONTROL SECTION 10.
001000******************************************************************
001100 100-START.
001200
001910 MOVE "D:\LSFPROD\LAW\PROD\SCRIPT\WFSPS.BAT" TO
001920 WS-CONVERT-SCRIPT.
001930 CALL "SYSTEM" USING WS-CONVERT-SCRIPT.
002000
002100 100-END.
002200
002300******************************************************************
002400 1000-SEL-REPORT SECTION 50.
002500******************************************************************
002600 1000-START.
005600
012500******************************************************************
012600 1000-END.
012700******************************************************************

create a .scr file and a .rpt file compile and test.