Dcl-ds DS_Response extname('ISSUERESP')
Resp_Printers Char(1215) Overlay ??
End-ds;
Key Fld Start Fld
Field Name Pos Typ Pos Len Field Text
---------- --- --- ----- ----- ---- --- --------------------------------------------------
PRTTYPDFRP A 696 10 Printer Type - Default Start the field here
PRTTRYAERP A 1910 1 Printer Tray - Alternate End the field here
There are a lot fields in between. There are 15 array elements in the 1215 character portion of the DS
One array element would be:
PRTTYPDFRP A 696 10 Printer Type - Default
PRTNAMDFRP A 706 10 Printer Name - Default
PRTNIDDFRP A 716 60 Printer Network ID - Default
PRTTRYDFRP A 776 1 Printer Tray - Default
I want to place the 15 elements into a DS:
Dcl-DS Ds_Printers Qualified Dim(15);
printerType Char(10);
printerName Char(10);
networkID Char(60);
trayNumber Char(1);
End-DS;
Extract and Array from a Free Form External Ds
Extract and Array from a Free Form External Ds
I have an external character data structure that is 1910 characters. I want to group the last several contiguous fields in the structure into one field so I can store the information in an array and then build a JSON string including it. The field would cover the last 1215 characters of the external DS. How would I define that field in the program within the external DS? Thanks
-
- Site Admin
- Posts: 671
- Joined: Sun Jul 04, 2021 5:12 am
Re: Extract and Array from a Free Form External Ds
Reposting code snippets with code tags -- since I found the original post very difficult to read.
Code: Select all
Dcl-ds DS_Response extname('ISSUERESP')
Resp_Printers Char(1215) Overlay ??
End-ds;
Code: Select all
Key Fld Start Fld
Field Name Pos Typ Pos Len Field Text
---------- --- --- ----- ----- ---- --- --------------------------------------------------
PRTTYPDFRP A 696 10 Printer Type - Default Start the field here
PRTTRYAERP A 1910 1 Printer Tray - Alternate End the field here
There are a lot fields in between. There are 15 array elements in the 1215 character portion of the DS
One array element would be:
PRTTYPDFRP A 696 10 Printer Type - Default
PRTNAMDFRP A 706 10 Printer Name - Default
PRTNIDDFRP A 716 60 Printer Network ID - Default
PRTTRYDFRP A 776 1 Printer Tray - Default
Code: Select all
Dcl-DS Ds_Printers Qualified Dim(15);
printerType Char(10);
printerName Char(10);
networkID Char(60);
trayNumber Char(1);
End-DS;
-
- Site Admin
- Posts: 671
- Joined: Sun Jul 04, 2021 5:12 am
Re: Extract and Array from a Free Form External Ds
I think you want something like the following (if I understand you correctly).
Code: Select all
dcl-ds ds_response ext extname('ISSUERESP') qualified;
dcl-ds Resp_Printers dim(15) samepos(PRTTYPDFRP);
printerType char(10);
printerName char(10);
networkId char(60);
trayNumber char(1);
end-ds;
end-ds;
Re: Extract and Array from a Free Form External Ds
My apologies for not formatting it well. I should have also stated that I'm on 7.2. We have 7.4 on the dev box but can't use it until all prod LPAR's have been upgraded. RDI flagged samepos as a keyword that is not allowed on a DS definition. So given being on 7.2, I'm not sure what to do. Thanks Scott.
-
- Site Admin
- Posts: 671
- Joined: Sun Jul 04, 2021 5:12 am
Re: Extract and Array from a Free Form External Ds
Unfortunately, it means you probably will need to hard-code the position.
Code: Select all
dcl-ds ds_response ext extname('ISSUERESP') qualified;
dcl-ds Resp_Printers dim(15) pos(696);
printerType char(10);
printerName char(10);
networkId char(60);
trayNumber char(1);
end-ds;
end-ds;
Re: Extract and Array from a Free Form External Ds
Thank you so much Scott. That worked fine. Thank you for YAJL as well.