MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
bjain Beginner Joined: 28 Nov 2003 Posts: 2 Topics: 1
Posted: Fri Nov 28, 2003 3:39 am Post subject: Template construction
Need your Help !!
Folliwng is the problem :
After retriving from SQL query. I will get the count.
For eg. Count is 3.
I will again pass cd : FFL
So Now I will be having count =3 and cd = FFL
with these two things I need a output of :
(%F1 %, %F2 %, %A %F3 %L3)
% IS A DELIMITER , F IS first name, L is last name and A='and'.A comma is placed between templated components(exceptat the end where the %A value is present )
In the above example if the count is 4, then the output will be
(%F1 %, %F2 %, %F3 %, %A %F4 %L4)
can you please guide me how to do it.
Thanks and Regards,
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Dec 01, 2003 2:32 pm Post subject:
Buntyjain,
A couple of clarifications. What will be the max value of the sql-count. Let us say if the sql count is 2 digits say 99, then will the output be
Code:
(%F01 %, %F02 %, %F03 %, %F04 %, %F05 %, %F06 %, %F07 %, %F0... %A %F99 %L99)
If the count is just a single digit then the following code will give you the desired results.
Code:
WORKING-STORAGE SECTION.
01 W-SQL-COUNT PIC S9(04) COMP.
01 W-SUB PIC S9(04) COMP.
01 W-MAX PIC S9(04) COMP.
01 W-OUTPUT PIC X(80).
01 W-STR PIC X(03).
01 W-OUT1.
05 W-PAR1 PIC X(01) VALUE '('.
05 W-OUT-STR1 OCCURS 0 TO 100 TIMES
DEPENDING ON W-MAX.
10 W-DLM1 PIC X(01) VALUE '%'.
10 W-FLD1 PIC X(01) VALUE ' '.
10 W-NUM1 PIC 9(01).
10 W-DLM2 PIC X(02) VALUE ' %'.
10 W-SEP PIC X(02) VALUE ', '.
05 W-OUT-STR2.
10 W-DLM3 PIC X(02).
10 W-DLM4 PIC X(02).
10 W-FLD2 PIC X(01).
10 W-NUM2 PIC 9(01).
05 W-OUT-STR3.
10 W-DLM5 PIC X(02).
10 W-FLD3 PIC X(01).
10 W-NUM3 PIC 9(01).
10 W-PAR2 PIC X(02).
PROCEDURE DIVISION.
MOVE 4 TO W-SQL-COUNT
MOVE 'FFL' TO W-STR
COMPUTE W-MAX = W-SQL-COUNT - 2
PERFORM VARYING W-SUB FROM 1 BY 1
UNTIL W-SUB > W-MAX
MOVE W-STR(1: 1) TO W-FLD1(W-SUB)
MOVE W-SUB TO W-NUM1(W-SUB)
END-PERFORM
MOVE W-STR(2: 1) TO W-FLD2
MOVE '%A' TO W-DLM3
MOVE ' %' TO W-DLM4
COMPUTE W-NUM2 = W-MAX + 1
MOVE W-STR(3: 1) TO W-FLD3
MOVE ' %' TO W-DLM5
MOVE W-SQL-COUNT TO W-NUM3
MOVE ')' TO W-PAR2
MOVE W-OUT1 TO W-OUTPUT
DISPLAY 'THE OUTPUT STR IS :' W-OUTPUT
GOBACK.
Change the code according to your needs.
Hope this helps...
cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
bjain Beginner Joined: 28 Nov 2003 Posts: 2 Topics: 1
Posted: Tue Dec 02, 2003 4:23 am Post subject:
Hi Kolusu,
Thanks for your response.
A couple of clarifications. What will be the max value of the sql-count. Let us say if the sql count is 2 digits say 99, then will the output be
Code:
(%F01 %, %F02 %, %F03 %, %F04 %, %F05 %, %F06 %, %F07 %, %F0... %A %F99 %L99)
Max value of the SQL-COUNT will be 25.
Yes the output will be
%F1 %, %F2 %, %F3 %, ................., %A %F25 %L25
Thanks again for your reply.
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum