SIMPLE LANSA TEMPLATE

Dumps file fields as comments
(from here you can modify to build group by ect..)

/* ********** ======================================================= */ /* ********** GET NAME OF JUST ONE PHYSICAL FILE */ /* ********** ======================================================= */ @@GET_FILS TO(1) PROMPT('Enter the name of the PHYSICAL file to be used by this template') EXTEND('The file name may be specified in full, partially (to cause a partial list' 'of available files to be displayed) or left blank (to cause a full list of' 'available files to be displayed). When a list of files is displayed, the' 'file required may be selected from the list.' ' ' 'Use the HELP function key for more details about this template and' 'examples of the type of RDML applications it can create.') HELPIDS(HELP010 HELP020 HELP030 HELP040 HELP050) @@COMMENT COMMENT('=======================================================') @@COMMENT COMMENT(' Simple File Dump ') @@COMMENT COMMENT(' ') @@COMMENT COMMENT(' @@FNAME01 - Field List ') @@COMMENT COMMENT(' ') @@COMMENT COMMENT(' Template - Z_Filedump ') @@COMMENT COMMENT(' ') @@COMMENT COMMENT(' FILE INFO ') @@COMMENT COMMENT(' @@FLIBR01 - File Library ') @@COMMENT COMMENT(' @@FVERS01 - File Version No ') @@COMMENT COMMENT(' @@FTYPE01 - File Type ') @@COMMENT COMMENT(' @@FNAME01 - File Name ') @@COMMENT COMMENT('=======================================================') /* ********** ======================================================= */ /* ********** GET FIELDS OF CHOSEN FILE INTO LIST 1 */ /* ********** ======================================================= */ @@CLR_LST NUMBER(1) @@RTV_FLDS FROM_FILE(1) INTO_LST(1) /* ********** ======================================================= */ /* ********** GET KEYS OF CHOSEN FILE INTO LIST 2 */ /* ********** ======================================================= */ @@CLR_LST NUMBER(2) @@RTV_KEYS OF_FILE(1) INTO_LST(2) /* ********** ======================================================= */ /* ********** GET USER TO CHOOSE FIELDS TO APPEAR ON PANEL */ /* ********** AND PUT RESULTS INTO LIST 3 */ /* ********** ======================================================= */ @@CLR_LST NUMBER(3) @@MAK_LSTS FROM_LSTS(1) FORCE_LSTS(2) INTO_LSTS((3 'Fields to' 'Appear in' 'Comments ' *SEQUENCE *ALL)) HELPIDS(HELP010 HELP020 HELP030 HELP040 HELP050) @@COMMENT 'Function control options' @@SET_IDX IDX_NAME(DP) TO(1) @@SET_IDX IDX_NAME(KF) TO(1) K30: @@LABEL @@CMP_IDX IDX_NAME(KF) IDX_VALUE(@@LNE03) IF_GT(K40) @@COMMENT COMMENT('#@@LEL03KF TYPE(@@LTP03KF) @@LDS03KF @@LAT03KF') @@INC_IDX IDX_NAME(DP) @@INC_IDX IDX_NAME(KF) @@GOTO LABEL(K30) K40: @@LABEL /* ********** ======================================================= */ /* ********** CLEAR ALL LISTS USED */ /* ********** ======================================================= */ @@CLR_LST NUMBER(1) @@CLR_LST NUMBER(2) @@CLR_LST NUMBER(3)

How to Send / Receive JSON to LANSA WAMS

This is some cool stuff.  I need to refresh some files on our application server from some presentation servers on AWS.  Here is my example so I don’t forget how to do this.  I hope this helps.

The easiest way to approach this is to build a wam *json that just dumps the file out.

  • JSONINPT WAM Below

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_WAM) Layoutweblet(‘std_blank_layout’)

Webroutine Name(ShowWork) Response(*JSON)
Web_Map For(*OUTPUT) Fields(#outlist)

Def_List Name(#outlist) Fields(#EDIV #ESTAT #EPACH #EDNAM #EIMAG002 #EIMAG2001 #EIMAG3 #EHOMB #EHOMS #ETHEM #EDESG #ERETL #ERESD #ECOMD #EPR #EEXTR1 #EEXTR2 #ECRUSR) Type(*Working) Entrys(*MAX)

#std_num := 0

*
Select Fields(#EDIV #ESTAT #EPACH #EDNAM #EIMAG002 #EIMAG2001 #EIMAG3 #EHOMB #EHOMS #ETHEM #EDESG #ERETL #ERESD #ECOMD #EPR #EEXTR1 #EEXTR2 #ECRUSR) From_File(M55E100)
Add_Entry To_List(#outlist)
#std_num := #std_num + 1
*
Leave If(#STD_NUM *GT 9)
Endselect

Endroutine

YOURLANSASERVER/CGI-BIN/lansaweb?wam=JSONINPT&webrtn=ShowWork&ml=LANSA:XHTML&part=YWD&lang=ENG

 

THIS IS the OUTPUT WHEN FILE IS EMPTY

{“webroutine”:{“context”:{“action-request”:”/CGI-BIN/lansaweb”,”dec-separator”:”.”,”images-path”:”/IMAGES”,”iso-lang”:”en”,”language”:”ENG”,”partition”:”YWD”,”service-name”:”JSONINPT_ShowWork”,”session-key”:””,”session-key-method”:”hidden”,”session-key-name”:”_SESSIONKEY”,”technology-service”:”LANSA:XHTML”,”user-id”:”LANDEVPGM”,”webapplication”:”JSONINPT”,”webapplication-title”:”Test JSON input”,”webroutine”:”ShowWork”,”webroutine-title”:””},”lists”:{“OUTLIST”:{“header”:[{“name”:”EDIV”},{“name”:”ESTAT”},{“name”:”EPACH”},{“name”:”EDNAM”},{“name”:”EIMAG002″},{“name”:”EIMAG2001″},{“name”:”EIMAG3″},{“name”:”EHOMB”},{“name”:”EHOMS”},{“name”:”ETHEM”},{“name”:”EDESG”},{“name”:”ERETL”},{“name”:”ERESD”},{“name”:”ECOMD”},{“name”:”EPR”},{“name”:”EEXTR1″},{“name”:”EEXTR2″},{“name”:”ECRUSR”}],”entries”:[]}}}}

This is input with one entry in list

{“webroutine”:{“fields”:{“STD_NUM”:{“value”:1}},”lists”:{“MYLIST”:{“header”:[{“name”:”EDIV”},{“name”:”ESTAT”},{“name”:”EPACH”},{“name”:”EDNAM”},{“name”:”EIMAG002″},{“name”:”EIMAG2001″},{“name”:”EIMAG3″},{“name”:”EHOMB”},{“name”:”EHOMS”},{“name”:”ETHEM”},{“name”:”EDESG”},{“name”:”ERETL”},{“name”:”ERESD”},{“name”:”ECOMD”},{“name”:”EPR”},{“name”:”EEXTR1″},{“name”:”EEXTR2″},{“name”:”ECRUSR”}],”entries”:[[“ALL”,”P”,”P”,”Studio Source”,”/IMG/PRODUCTS/BRANDS/MASTHEAD/MAGNUMSOURCEMASTHEAD”,””,”/IMG/PRODUCTS/BRANDS/LOGOS/MAGNUMSOURCELOGO”,”N”,”N”,”N”,”N”,”N”,”Y”,”Y”,”Y”,””,””,””]]}}}}

 

This is WAM ROUTINE TO DIGEST JSON

Webroutine Name(TEST) Response(*JSON)

Web_Map For(*both) Fields(#STD_NUM)
Web_Map For(*input) Fields(#mylist)
Web_Map For(*output) Fields(#mylist2)
Def_List Name(#mylist) Fields(#EDIV #ESTAT #EPACH #EDNAM #EIMAG002 #EIMAG2001 #EIMAG3 #EHOMB #EHOMS #ETHEM #EDESG #ERETL #ERESD #ECOMD #EPR #EEXTR1 #EEXTR2 #ECRUSR) Type(*Working) Entrys(*MAX)
Def_List Name(#mylist2) Fields(#EDIV #ESTAT #EPACH #EDNAM #EIMAG002 #EIMAG2001 #EIMAG3 #EHOMB #EHOMS #ETHEM #EDESG #ERETL #ERESD #ECOMD #EPR #EEXTR1 #EEXTR2 #ECRUSR) Type(*Working) Entrys(*MAX)
#std_num := #std_num + 1

 

Clr_List Named(#mylist2)

Selectlist Named(#mylist)
Insert Fields(#EDIV #ESTAT #EPACH #EDNAM #EIMAG002 #EIMAG2001 #EIMAG3 #EHOMB #EHOMS #ETHEM #EDESG #ERETL #ERESD #ECOMD #EPR #EEXTR1 #EEXTR2 #ECRUSR) To_File(M55E100) Issue_Msg(*YES)
Add_Entry To_List(#mylist2)
Endselect

 

Endroutine

 

OK Now the FUN PART.  You will download fiddler to send the JSON Data.  Look at picture.   Also, I am available for projects..

Click on the Composer tab

COPY your URLand Select POST http/1.1
and use

Host: YOURURL
Content-Length: 0
Content-Type: application/json; charset=UTF-8

PUT YOUR JSON in THE REQUEST BODY

 

WAM JSON
LANSA WAM JSON EXAMPLE