Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to loop through few records? 1

Status
Not open for further replies.

annettesue

Technical User
Feb 10, 2003
29
MY
I am new to progress dynamics.i want to print a range of serial numbers for each order that user key in. e.g. Order: 11,15,23,45...,
serial number for such orders with be printed out accordingly.i've prepared 10 fields for user to key in the
order but it's not necessary for them to key in every fields. At my viewer procedure, i pass all the
fields' parameter in a string(regardless if it is filled) to my PLIP prosedure to run the print function. I am not sure
how to loop through the parameter string to find the field that is filled and print out the serial numbers accordingly.
Below is the example(in my viewer procedure).Please advice.

pc_parameter = "".
pc_parameter = pc_parameter + gc_s1 + CHR(1).
pc_parameter = pc_parameter + gc_s2 + CHR(1).
pc_parameter = pc_parameter + gc_s3 + CHR(1).
pc_parameter = pc_parameter + gc_s4 + CHR(1).
pc_parameter = pc_parameter + gc_s5 + CHR(1).
pc_parameter = pc_parameter + gc_s6 + CHR(1).
pc_parameter = pc_parameter + gc_s7 + CHR(1).
pc_parameter = pc_parameter + gc_s8 + CHR(1).
pc_parameter = pc_parameter + gc_s9 + CHR(1).
pc_parameter = pc_parameter + gc_s10.

/*launch my super procedure to run the print function*/
{dynlaunch.i
&PLIP = 'myprocedure_pp.r'
&IProc = 'pList'
&mode1 = INPUT
&parm1 = pc_parameter
&datatype1 = CHARACTER
&mode2 = OUTPUT
&parm2 = pc_msg
&datatype2 = CHARACTER
}

regards.
 
def var i as int no-undo.
do i = 1 to num-entries(pc_parameter,chr(1)):
assign <this_item> = entry(i,pc_parameter,chr(1)).
<do some processing>
end.

The num-entries and entry functions take an optional last parameter of <delimiter>, with a default of comma. In this case, your parameters are delimited by chr(1).


Mike.
 
Mike, may I know what's the meaning by <this_item>.By the way, do I need to break my string of pc_parameter into something like below and open query to refer to the serial number's table(so that i can get the serial number for particular order),

c_s1 = ENTRY(1, pc_parameter,CHR(1)).
c_s2 = ENTRY(2, pc_parameter,CHR(1)).
c_s3 = ENTRY(3, pc_parameter,CHR(1)).
c_s4 = ENTRY(4, pc_parameter,CHR(1)).
c_s5 = ENTRY(5, pc_parameter,CHR(1)).
c_s6 = ENTRY(6, pc_parameter,CHR(1)).

before I do the looping?

regards,
annette
 
Annette,

<this_item> is just some other local variable that you define in your plip.

I've re-read your first posting, and to me it looks like you need something on the lines of ...
Code:
do i = 1 to num-entries(pc_parameter,chr(1)):
    for first order no-lock
          where order>ordernum = integer(entry(i,pc_parameter,chr(1))),
        each serialnumber of order no-lock:

        <do some processing>
    end.
end.
Of course I don't know what your tables are really called or whether it's more appropriate to build a dynamic query, but the general principle is to extract the parameters one by one, retrieve the order associated with each parameter (if there is one), and process accordingly.

Hope this helps.


Mike.
 
Hello Mike,
many many**thanks to your help. I've manage to solve my previous problem using what you've suggested...^o^...
Now I m facing some layout problem..I would like my layout to be something like:

123456 123457
123458 123459

How am i going to arrange it? I tried to use MOD(m/2)....but failed.

m=0.
...(some process)
m = m + 1.
IF MOD(m/2) THEN
PUT STREAM s_stream
serialnum SKIP.
ELSE DO:
PUT STREAM serialnum SPACE(8).
END.

regards.
 
Annette,

The MOD function returns an integer, so test for an even number in your IF statement. Also, if I remember correctly, you need a space before and after your operand. Here's the amended code ...
Code:
m=0.
...(some process)
m = m + 1.
IF MOD(m / 2) = 0 THEN
     PUT STREAM s_stream
           serialnum SKIP.
ELSE DO:                            
     PUT STREAM serialnum SPACE(8).  
END.

Mike.
 
I've found out that dynamics don't recognize MOD and keep prompt out error &quot;Unknown or could not understand line after --&quot;MOD&quot;&quot;, so I've changed it to use just m = 2 and it's work fine...now my problem is: although i did a loop for my pc_parameter, it only prints out the ordernum for the FIRST field that i filled. For the rest of the fields, it failed. That's mean the loop can be considered failed because it doesn't check for the rest of the fields. Can You help me to fix the problem?

regards.
 
Annette,

My bad. The correct Progress syntax for the MOD function is:
expression MODULO base
So in your case the If statement should read
Code:
IF m MODULO 2 = 0 THEN ... etc
As for the rest, I think you'll need to post the code you're using together with a small data sample, then there's a better chance of figuring out where the problem lies.


Mike.
 
Sorry for disturbing..I am really struggling to do this program.

This is what i am doing now..I manage to print out the serialnum according to ORDER that user key in. The problem that i encounter is:
1. I want to print out serialnum for that particular order in one page but it came out where all the serialnum for every order user key in printed in 1 page.
2. I am not sure how to change alphabet for every 6 ordernum.
3. I dont know how to get itemtype for MODE from other table.


Below is how my container/window looks like:


CODE: (fill-in for user key in as reference only)
FIELD: (A/B/C) - radio button

ORDER:
(10 fill-in for user to key in)
....



BELOW is what i wish to print out:
- if order.partnum = item.partnum THEN get the itemtype from item table
- the alphabet will change for every 6 ordernum.(i.e from A,B,C.....to Z)

NO.: <order.ordernum> - 'alphabet' CODE: (user key in)
ORDER: <order.order> MODE: <item.itemtype>
DATE: <current date> NAME: <username>
PART NO.: <order.partnum> - <Field>

SerialNO <order.serial>
=======
32YU456 32YU457
32YU458 32YU459
... ...
... ...
(until 20 fields being filled)

Here is my code....

/*Still in progress, not complete*/
/* I use order table to do my SDO because most data are get from the table*/

DEFINE INPUT PARAMETER pc_parameter AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pc_code AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pc_field AS CHARACTER NO-UNDO.

DEFINE OUTPUT PARAMETER pc_msg AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE m AS INTEGER NO-UNDO.
DEFINE VARIABLE c_serialnum AS CHARACTER NO-UNDO.
DEFINE VARIABLE c_order AS CHARACTER NO-UNDO.
DEFINE VARIABLE c_mode AS CHARACTER NO-UNDO.
DEFINE VARIABLE c_no AS CHARACTER NO-UNDO.
DEFINE VARIABLE c_code AS CHARACTER NO-UNDO.
DEFINE VARIABLE c_partnum AS CHARACTER NO-UNDO.
DEFINE VARIABLE c_field AS CHARACTER NO-UNDO.
DEFINE VARIABLE c_detail AS CHARACTER FORMAT &quot;X(80)&quot; NO-UNDO.

/*there are some error where item table cant be found*/
FIND FIRST item WHERE item.item = order.item NO-LOCK NO-ERROR.
IF AVAILABLE item THEN
ASSIGN c_mode = item.itemtype.

DO i = 1 TO NUM-ENTRIES(pc_parameter, CHR(1)):
FOR EACH order WHERE order.order = integer(ENTRY(i, pc_parameter,CHR(1))) NO-LOCK:
ASSIGN c_no = order.ordernum.
ASSIGN c_partnum = order.partnum

END.

c_code = pc_code.
c_field = pc_field.

/*initialize variables(i have defined in definition*/
dt_rptDate = TODAY.
c_time = STRING(TIME, &quot;hh:mm:ss&quot;).
c_auditReport = &quot;Order Print&quot;.
c_pgm = &quot;order_ps.r&quot;.
pc_msg = &quot;&quot;.
i_count = 0.
l_first = YES.


/*get the job nbr*/
RUN etserp/gen/geng_getjobnbr_ps.r (OUTPUT pi_jobNbr).

/*get the company Name*/
RUN pGetCompanyName IN THIS-PROCEDURE.
/*Create the joblog entry*/
RUN pCreateJobLog IN THIS-PROCEDURE.
/*get the user directory*/
RUN pUserDirectory IN THIS-PROCEDURE.

DEFINE FRAME fr_rptHeader HEADER c_no AT 10 FORMAT &quot;>>>>>>9&quot; &quot;-&quot; AT 19 c_code AT 33 SKIP c_order AT 10 c_mode AT 33 SKIP dt_rptDate AT 10 c_user AT 33 SKIP
c_partnum AT 10 c_field AT 28 WITH PAGE-TOP WITH WIDTH 200 WITH FONT 4.

DEFINE FRAME fr_rptFooter HEADER &quot;Output: &quot; c_auditFileDir FORMAT &quot;x(70)&quot; WITH PAGE-BOTTOM WITH WIDTH 200 WITH FONT 4.
OUTPUT STREAM s_stream TO VALUE(c_auditFileDir) LANDSCAPE PAGED PAGE-SIZE 40.

VIEW STREAM s_stream FRAME fr_rptHeader.


DO i = 1 TO NUM-ENTRIES(pc_parameter, CHR(1)):

ASSIGN c_order = ENTRY(i, pc_parameter,CHR(1)).
IF NOT c_order = &quot;&quot; THEN
DO:
m = 1.
FOR EACH order WHERE order.order = integer(c_order) NO-LOCK:
ASSIGN c_serialnnum = order.serial.

c_detail = c_detail + c_serialnum + &quot; &quot;.

IF m = 2 THEN DO:

PUT STREAM s_stream c_detail AT 10 SKIP(1).
c_detail = &quot;&quot;.
m = 0.

END.

m = m + 1.

END.
END.
END.

i_count = i_count + 1.
IF LINE-COUNTER(s_stream) > PAGE-SIZE(s_stream) THEN
VIEW STREAM s_stream FRAME fr_rptHeader.
PUT STREAM s_stream c_detail AT 10 SKIP(1).

/* CLOSE QUERY qry_Item. */

OUTPUT STREAM s_stream CLOSE.

RUN pEndJobLog.

END PROCEDURE.


Please advice.

Thanx.
regards,
annette
 
Annette,

1. At the end of the DO block for IF NOT c_order = &quot;&quot;, insert:
Code:
    PAGE STREAM s_stream.
and delete the stuff from IF LINE-COUNTER to /* CLOSE QUERY qry_Item. */

2. Not quite sure what you want to do here, but try this code in the procedure editor:
Code:
DEF VAR c AS CHAR INIT 'A'.
DEF VAR i AS INT.

DO i = 1 TO 10 WITH FRAME a DOWN:
    DISP c.
    ASSIGN c = CHR(ASC(c) + 1).
END.
3. Find the Item record inside the FOR EACH Order loop (the big one with the PUT STREAM in it).

And finally, I think the initial FIND on the Item record and that first FOR EACH Order loop are unneccessary.


Mike.
 
A BIG THANX for your help, Mike..I manage to solve most of the problems now..except for the alphabet problem. If i do the &quot;DO i = 1 TO 26 WITH FRAME..&quot; loop(coz I want to loop from A-Z), i'll get my output printed for 26 files from A to Z for the same order(ORDER) and number(NO.)..

Another thing I would like to ask you is: if I delete all the stuff from IF LINE-COUNTER to /* CLOSE QUERY qry_Item. */, how can I print to another page if my serialnum exceed 20 fields with number(NO.) = number + 1?

Thanks again.(^o^)

regards,
annette.
 
Mike,
I have manage to solve all the problem regarding this matter...i didn't use LINE-COUNTER...i just PAGE STREAM....and i have change my coding where i use a big DO to loop through all the records...then i print all the header accordingly....and then the numbers...

thanx for ur concern...

now i m facing another problem where i've stated in my new thread...Do you know how to write the procedure in my browser prosedure to get the value from calculated field of the viewer...i want to get the balance value:

Balance = All - Sold.

regards;
annette
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top