Focal Point
[SOLVED] Extracting portions of a long user input field into several subfields

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/49110608

April 13, 2009, 04:58 PM
ta2007
[SOLVED] Extracting portions of a long user input field into several subfields
I have a report requirement to display the names of 'reps' selected by the user on the launch page in the report header page the report. The rep data comes from the launch page as a single text string that is assigned to an &var, with user values separated by comma, space.

Ex. 'BURGER_A, BURNETTE_A, FLOGHBAER_B, TERRENCE_H, PRATT_K, WHITNEY_K, MINOURE_M, RUTGERS_M, JEFFERSON_R, WHITMORE_S, BULLHOUSE_S, DEGRASSE_T, ADAMS_V'

However, this is a dynamic field and the number of reps can change.

Right now, the field does not wrap in the heading and any parts of the field in excess of the display area 'fall off' the right side of the report. I need to develop dynamic code that will create an appropriate number of headings and place portions of the values into them for use in the build of the header section.

I can fit approximately 64 characters on the screen.

Ex:

REP_HDR_1 = 'BURGER_A, BURNETTE_A, FLOGHBAER_B, TERRENCE_H, PRATT_K,'
REP_HDR_2 = 'WHITNEY_K, MINOURE_M, RUTGERS_M, JEFFERSON_R, WHITMORE_S, BULLHOUSE_S,'
REP_HDR_3 = 'DEGRASSE_T, ADAMS_V'

Any ideas out there on how to loop this to get this output?

Thanks.

This message has been edited. Last edited by: Kerry,


7.6.4
XP SP3
EXL2K, HTML, PDF
April 13, 2009, 05:14 PM
GinnyJakes
Look up the PARAG subroutine.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
April 13, 2009, 10:21 PM
ta2007
I'm new to Web Focus, so I am probably not quite putting this together right. I have been trying to process the parag part in the set area. Closest I've gotten is the code below, but I can't figure out how to initialize a &var with a variable length of text. I tried initializing with with spaces or letters, but the extra characters appear as filler in the final cell. Also, When I tried to append a title for the actual header display in the second loop, the first line truncated. Copy code below into a blank report based off CAR to see what is happening:

-DEFAULT &SREP = 'BURGER_A, BURNETTE_A, FLOGHBAER_B, TERRENCE_H, PRATT_K, WHITNEY_K, MINOURE_M, RUTGERS_M, JEFFERSON_R, WHITMORE_S, BULLHOUSE_S, DEGRASSE_T, ADAMS_V';

-SET &SREP_CHAR_CNT = &SREP.LENGTH;
-SET &DISPL_LEN = 64;
-SET &SREPP = 'intitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitialize';
-SET &SREPP = PARAG(&SREP.LENGTH, &SREP, '~', &DISPL_LEN, &SREPP);
-SET &DISPL_ROWS = (&SREP_CHAR_CNT+(&DISPL_LEN-1))/&DISPL_LEN;

-SET &COUNTERA=1;
-REPEAT LOOP1 FOR &COUNTERA FROM 1 TO &DISPL_ROWS STEP 1;
-SET &SREP_HDR.&COUNTERA='intitializeintitializeintitializeintitializeintitializeintitializeintitialize';
-SET &SREP_HDR.&COUNTERA=GETTOK(&SREPP, &SREPP.LENGTH, &COUNTERA, '~', &SREPP.LENGTH, &SREP_HDR.&COUNTERA);
-LOOP1

-SET &COUNTERB=1;
-REPEAT LOOP2 FOR &COUNTERB FROM 1 TO &DISPL_ROWS STEP 1;
-SET &SVC_REP_HDR.&COUNTERB = 'intitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitializeintitialize';
-SET &SVC_REP_HDR.&COUNTERB=IF &COUNTERB EQ 1 THEN 'Service Rep(s): ' | &SREP_HDR.&COUNTERB ELSE &SREP_HDR.&COUNTERB ;
-LOOP2
-? &
-EXIT

How do I use parag and set statements properly to get just the actual output?

Thanks.


7.6.4
XP SP3
EXL2K, HTML, PDF
April 14, 2009, 03:35 AM
<JG>
Very good attempt.

1. no need to initialize the variables.
2. when using sub-routines in DM you must use a format not a variable name.

look at this

 
-DEFAULT &SREP = 'BURGER_A, BURNETTE_A, FLOGHBAER_B, TERRENCE_H, PRATT_K, WHITNEY_K, MINOURE_M, RUTGERS_M, JEFFERSON_R, WHITMORE_S, BULLHOUSE_S, DEGRASSE_T, ADAMS_V';

-SET &SREP_CHAR_CNT = &SREP.LENGTH;
-SET &DISPL_LEN = 64;
-SET &SREPP = ' ';
-SET &SREPP = PARAG(&SREP.LENGTH, &SREP, '~', &DISPL_LEN, 'A&SREP.LENGTH');
-SET &DISPL_ROWS = (&SREP_CHAR_CNT+(&DISPL_LEN-1))/&DISPL_LEN;

-SET &COUNTERA=1;
-REPEAT LOOP1 FOR &COUNTERA FROM 1 TO &DISPL_ROWS STEP 1;
-SET &SREP_HDR.&COUNTERA=' ';
-SET &SREP_HDR.&COUNTERA=GETTOK(&SREPP, &SREPP.LENGTH, &COUNTERA, '~', &SREPP.LENGTH, 'A64');
-LOOP1

-SET &COUNTERB=1;
-REPEAT LOOP2 FOR &COUNTERB FROM 1 TO &DISPL_ROWS STEP 1;
-SET &SVC_REP_HDR.&COUNTERB = ' ';
-SET &SVC_REP_HDR.&COUNTERB=IF &COUNTERB EQ 1 THEN 'SERVICE REP(S): ' | &SREP_HDR.&COUNTERB ELSE &SREP_HDR.&COUNTERB ;
-LOOP2
-TYPE &SVC_REP_HDR1
-EXIT
 

April 15, 2009, 05:29 PM
Waz
You could simplify this to:
-DEFAULT &SREP = 'BURGER_A, BURNETTE_A, FLOGHBAER_B, TERRENCE_H, PRATT_K, WHITNEY_K, MINOURE_M, RUTGERS_M, JEFFERSON_R, WHITMORE_S, BULLHOUSE_S, DEGRASSE_T, ADAMS_V';

-SET &SREP_CHAR_CNT = &SREP.LENGTH;
-SET &DISPL_LEN = 64;
-SET &SREPP = ' ';
-SET &SREPP = PARAG(&SREP.LENGTH, &SREP, '~', &DISPL_LEN, 'A&SREP.LENGTH');
-SET &DISPL_ROWS = (&SREP_CHAR_CNT+(&DISPL_LEN-1))/&DISPL_LEN;

-REPEAT LOOP1 FOR &COUNTERA FROM 1 TO &DISPL_ROWS STEP 1;
-SET &SREP_HDR.&COUNTERA=' ';
-SET &TEMP = GETTOK(&SREPP, &SREPP.LENGTH, &COUNTERA, '~', &SREPP.LENGTH, 'A64');
-SET &SREP_HDR.&COUNTERA=IF &COUNTERA EQ 1 THEN 'SERVICE REP(S): ' | &TEMP ELSE &TEMP ;
-TYPE &SREP_HDR.&COUNTERA
-LOOP1

-EXIT



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

April 22, 2009, 03:05 PM
ta2007
Thanks all. The tips given by JG and WAZ helped clear up the initial issue of parsing; I am getting the right number of dynamic placeholders and the text is going in right.

This is a spinoff question: How do I get these objects, which are created on the fly, to be placed in the heading section? Can you create loops within the ON TABLE PAGE-BREAK section (the actual report header)? I tried to create a loop within this area to call/create "&SREP_HDR.&COUNTERA ", but it did not like my attempts.


7.6.4
XP SP3
EXL2K, HTML, PDF
April 23, 2009, 05:53 AM
Kofi
You put loop inside HEADING -

HEADING
" This is haeding <+0> &DATEDTMYY"
-DEFAULT &SREP = 'BURGER_A, BURNETTE_A, FLOGHBAER_B, TERRENCE_H, PRATT_K, WHITNEY_K, MINOURE_M, RUTGERS_M, JEFFERSON_R, WHITMORE_S, BULLHOUSE_S, DEGRASSE_T, ADAMS_V';

-SET &SREP_CHAR_CNT = &SREP.LENGTH;
-SET &DISPL_LEN = 64;
-SET &SREPP = ' ';
-SET &SREPP = PARAG(&SREP.LENGTH, &SREP, '~', &DISPL_LEN, 'A&SREP.LENGTH');
-SET &DISPL_ROWS = (&SREP_CHAR_CNT+(&DISPL_LEN-1))/&DISPL_LEN;

-REPEAT LOOP1 FOR &COUNTERA FROM 1 TO &DISPL_ROWS STEP 1;
-SET &SREP_HDR.&COUNTERA=' ';
-SET &TEMP = GETTOK(&SREPP, &SREPP.LENGTH, &COUNTERA, '~', &SREPP.LENGTH, 'A64');
-SET &SREP_HDR.&COUNTERA=IF &COUNTERA EQ 1 THEN 'SERVICE REP(S): ' | &TEMP ELSE &TEMP ;
-TYPE "&SREP_HDR.&COUNTERA"
-LOOP1
I think this work, no test though Frowner

Kofi


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
April 23, 2009, 04:02 PM
ta2007
Kofi,

Your approach worked. The final code ended up being:

ON TABLE PAGE-BREAK
-SET &SREP_CHAR_CNT = &SREP.LENGTH;
-SET &DISPL_LEN = 64;
-SET &SREPP = ' ';
-SET &SREPP = PARAG(&SREP.LENGTH, &SREP, '~', &DISPL_LEN, 'A&SREP.LENGTH');
-SET &DISPL_ROWS = (&SREP_CHAR_CNT+(&DISPL_LEN-1))/&DISPL_LEN;
-SET &FRMTLEN = 'A' | &DISPL_LEN;

-REPEAT LOOP1 FOR &COUNTERA FROM 1 TO &DISPL_ROWS STEP 1;
-SET &SREP_HDR.&COUNTERA=' ';
-SET &TEMP = GETTOK(&SREPP, &SREPP.LENGTH, &COUNTERA, '~', &SREPP.LENGTH, '&FRMTLEN');
-SET &SREP_HDR.&COUNTERA=IF &COUNTERA EQ 1 THEN 'Service Rep(s): ' | &TEMP ELSE &TEMP ;
"&SREP_HDR.&COUNTERA "
-LOOP1

Thanks All!


7.6.4
XP SP3
EXL2K, HTML, PDF
April 23, 2009, 04:09 PM
ta2007
One last formatting tip for those using this code...I found it easier to set up any formatting (font, centering, underline, bold, etc) to be used on these rows that were created on the fly in the general category for that area. Since I couldn't predict how many rows would be created, it lets WF have a 'default'. See below:

TYPE=TABHEADING,
OBJECT=TEXT,
JUSTIFY=CENTER,
SIZE=10,
FONT='ARIAL',
$
TYPE=TABHEADING,
LINE=1,
STYLE=BOLD+UNDERLINE,
SIZE=14,
JUSTIFY=CENTER,
$
TYPE=TABHEADING,
LINE=2,
STYLE=BOLD+UNDERLINE,
SIZE=14,
JUSTIFY=CENTER,
$

1st two lines were report headers with their own formatting. Their formatting is specified by Line=1 and Line=2. All of the criteria rows I showed (which came after these two rows and include the ones created on the fly) were formatted based on TABHEADING data.


7.6.4
XP SP3
EXL2K, HTML, PDF
April 24, 2009, 04:54 AM
Kofi
I pleased to help, this good Forum. Smiler

Kofi


Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012