Page 1 of 2

Create dynamic WS-Header using REXX

PostPosted: Mon Apr 06, 2015 7:50 pm
by arpitpatel01
Hi,
I have this requirement to create a tool using REXX wherein user will provide Header Variables and then REXX will calculate its length and provide to output.

Input:
Name
Contact
AddressLine1
AddressLine2


Output should be
01 WS-HEADER.
     05 WS-HDR1  PIC X(04) VALUE 'Name'.
     05 WS-HDR2  PIC X(07) VALUE 'Contact'.
     05 WS-HDR3  PIC X(12) VALUE 'AddressLine1'.
     05 WS-HDR4  PIC X(12) VALUE 'AddressLine2'.


where, WS-HEADER AND WS-HDR* variables will be constant.

I am new to REXX. Kindly assist.

Thank you in advance!

Code'd

Re: Create dynamic WS-Header using REXX

PostPosted: Mon Apr 06, 2015 7:58 pm
by BillyBoyo
I think you'll have to provide a number of worked examples, and explain why this is needed.

Re: Create dynamic WS-Header using REXX

PostPosted: Mon Apr 06, 2015 8:24 pm
by enrico-sorichetti
does not seem overly complicated to me

const.1 = "Name"
const.2 = "Contact"
const.3 = "AddressLine1"
const.4 = "AddressLine2"
const.0 = 4

say "01 WS-HEADER."
do    i = 1 to const.0
   l = right(length(const.i),2,"0")
   say "  05 WS-HDR"i" PIC X("l") VALUE '"const.i"'."
end


to obtain
01 WS-HEADER.
  05 WS-HDR1 PIC X(04) VALUE 'Name'.
  05 WS-HDR2 PIC X(07) VALUE 'Contact'.
  05 WS-HDR3 PIC X(12) VALUE 'AddressLine1'.
  05 WS-HDR4 PIC X(12) VALUE 'AddressLine2'.

Re: Create dynamic WS-Header using REXX

PostPosted: Mon Apr 06, 2015 9:16 pm
by BillyBoyo
But what is going to be done with that, and how will it be used?

It gets a piece of data like this, for the example:

NameContactAddressLine1AddressLine2


For a different user, different output:

enricoencico@gmail.conBase Camp 1High Mountain


Without knowing the data-layout for each case, how will the data be used? If it is just some static data to mark the owner of a program, it can just be done as comments. If it is to be used, how will it be used without tortuous code?

Re: Create dynamic WS-Header using REXX

PostPosted: Mon Apr 06, 2015 9:19 pm
by enrico-sorichetti
my understanding is that the TS has some constants to be spread into some cobol declares
so no reason to investigate further :mrgreen:

Re: Create dynamic WS-Header using REXX

PostPosted: Mon Apr 06, 2015 11:04 pm
by BillyBoyo
Looks to me like an ill-thought waste of time, but at least they got some nice code from it :-)

There can only be one of these per program (the names cannot be made unique, so the data can't be referenced), so must be for different programs. Since they can't be used programatically in a sensible way as they stand, there seems little point. If they are just to assign personnel, better as generated comments.

Anyway, they've put such effort into it, I suspect the Tool will make it, whatever it is supposed to do.

Re: Create dynamic WS-Header using REXX

PostPosted: Tue Apr 07, 2015 1:30 am
by enrico-sorichetti
what I find odd is the need to ask on a forum how to solve such a simple problem!

Re: Create dynamic WS-Header using REXX

PostPosted: Tue Apr 07, 2015 4:40 am
by Pedro
re: the need to ask

FYI: from the page title: "IBM MAINFRAME FORUM, A Help & Support Forum for Mainframe Beginners and Students"

As a beginner, the OP probably does not understand the problem well enough to ask the right question.

My guess is he wants to use the field names as the labels and to use a max length of the field:
01 WS-HEADER.
05 WS-name         PIC X(30).
05 WS-contact      PIC X(30).
05 WS-addressline1 PIC X(25).
05 WS-addressline1 PIC X(25).

Re: Create dynamic WS-Header using REXX

PostPosted: Tue Apr 07, 2015 1:03 pm
by enrico-sorichetti
My guess is he wants to use the field names

I beg to disagree ;)

the output sample posted seemed clear enough

Output should be
01 WS-HEADER.
05 WS-HDR1 PIC X(04) VALUE 'Name'.
05 WS-HDR2 PIC X(07) VALUE 'Contact'.
05 WS-HDR3 PIC X(12) VALUE 'AddressLine1'.
05 WS-HDR4 PIC X(12) VALUE 'AddressLine2'.

Re: Create dynamic WS-Header using REXX

PostPosted: Tue Apr 07, 2015 9:26 pm
by Pedro
the output sample posted seemed clear enough

Yeah, you guys answered the question that was asked. but you also belittled him for even asking the question. My assumption is that he is not experienced enough to ask the right question, nor to give the right sample results.