Hi Sanjeebkumar,

you have to pass variables from the calling program to the subroutine, otherwise they will not be defined in the subroutine.
Line 12 in your calling program (MAIN) should therefore look like this:
CALL SUB(REC)
and line 1 in your subroutine (SUB) should be
SUBROUTINE SUB(REC) - The SUBROUTINE statement should always be the first line in every program, that is likely to be called. You may pass multiple variables i.e. CALL SUB(VAR1,VAR2,...) whereby the variable names can be different in calling and called program - i.e. SUBROUTINE SUB(A,B,...) - In this case A will contain the value of VAR1, B the value of VAR2 and so on. Important is, that the number of passed variables has to be the same in calling and called programs!


You can also pass variables using COMMON, but I don't want to get into that, since you seem to be a real newbie, and I don't want to confuse you. In the MV-world there is usually always more than one solution. I also suggest to write the PRINTER ON (before the LOOP statement) and PRINTER OFF (after the REPEAT statement) statements in your calling program (MAIN), since you create a lot of overhead otherwise.

Sorry, but with the second error message, I cannot help you - I've never encountered this one.
Maybe you haven't set up a valid printer on your system?

I hope that helps you at least a bit

Mecki Foerthmann

Sanjeebkumar Sarangi wrote:
Hi
I tried to generate a report by writing a small program. But I got an error
as below.

ERROR:

RUN TEST.BP MAIN
MAIN

45 record(s) selected to SELECT list #0.
Program "SUB": Line 3, Variable "REC" previously undefined.  Empty string
used.
Program "SUB": Line 3, Printer name UVDEFAULT is not recognized by the
system.

CODE:

ED TEST.BP
Record name = MAIN
15 lines long.

----: P
0001: CRT 'MAIN'
0002: OPEN 'INVENTORY.T' TO INEVNTORY ELSE STOP
0003: SENT = 'SSELECT INVENTORY.T BY ITEM_CODE'
0004: EXECUTE SENT
0005: EOF = 0
0006: LOOP
0007: READNEXT ITEM_CODE ELSE
0008: EOF = 1
0009: END
0010: UNTIL EOF DO
0011: READ  REC FROM INEVNTORY ,ITEM_CODE THEN
0012: CALL SUB
0013: END
0014: REPEAT
0015: STOP
Bottom at line 15.
----: Q

File name        = TEST.BP
Record name = SUB
6 lines long.

----: P
0001:CRT 'SUB'
0002: PRINTER ON
0003: PRINT "ITEM_CODE"  "L#16":REC<1>
0004: PRINT "DESCRIPTION"  "L#16": REC<2>
0005: PRINT "TYPE"  "L#16":REC<3>
0006: PRINTER OFF
0007: RETURN
Bottom at line 7.
----:
How do I resolve this?


Thanks
Sanjeeb
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/



                
___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to