Build an object upon user defined in map

Hi,

I need to build a new object (Local object, and save it only) , upon a list of variables given in a user map.
The user load my program, and needs to fill up a map with variables names and types.
What API’s should I use to perform it?

With Regards,
Hezi

Hi Hezi;

I am having trouble understanding your question.

Could you indicate which of the following is true.

  1. You have a Map, probably written by someone else. You need to write an INPUT statement with proper variables being passed to the Map.

  2. You want to create a separate Data Area with the variables needed for the Map. In your program, in your Local Data Area, you want to have a USING clause of the separate Data Area.

  3. Neither 1) or 2) is true.

If neither 1) or 2) is true, could you try to reword the question.

Let me try to explain:
I need to build a Local data area object (linux os), upon a user filling a map with a variables definition (name, type & length) and to save as a given name too

Later on the object will be ‘cat’, but not in my app.

Use

DEFINE PRINTER (nn) OUTPUT 'SOURCE'

and WRITE (nn) statements to copy the variables and their formats to the Source Work Area. Then use the W function of USR4201N to convert the SWA contents to an LDA.

Hi,

That what exactly I was looking for.
Somehow I gets error 1100, for not writing ‘DEFINE DATA’ at the beginning, although I do.
Do you have any idea?

It is likely that you have forgotten that the WRITE statement produces a standard report, despite the output going to SOURCE.

You need to avoid the default ‘page eject’ lines (‘*/’) by coding

EJECT OFF

and you need to avoid the default report title by coding

WRITE NOTITLE

Here is a working example. For simplicity I have initialized an internal array with the field definitions.

DEFINE DATA LOCAL
1 P-FUNCTION (A1)  INIT <'W'>
1 P-FORMAT (A1)  INIT <'D'>
1 P-OBJECT-TYPE (A1)  INIT <'L'>
1 P-OBJECT-NAME (A8)  INIT <'RGZLDA'>
1 P-OBJECT-LIBRARY (A8)  INIT <*LIBRARY-ID>
1 P-LIBRARY-DBID (N5)
1 P-LIBRARY-FNR (N5)
1 P-LIBRARY-PASSWORD (A8)
1 P-LIBRARY-CIPHER (A8)
1 P-WRITE-ERROR-MODE (A1) INIT <'E'>
1 P-RETURN-CODE (I4)
1 P-RETURN-MESSAGE (A250)
1 P-FSEC-DBID (N05)
1 P-FSEC-FNR (N05)
1 P-FSEC-PSW (A08)
1 P-FSEC-CIP (N08)
1 ## (I4)                    CONST <7>
1 #LDA (A72/##)               INIT <'DEFINE DATA LOCAL'
                                  ,'1 #F1(A10)'
                                  ,'1 #F2 (N3)'
                                  ,'1 #F3 (P5)'
                                  ,'1 #F4 (I1)'
                                  ,'END-DEFINE'
                                  ,'END'
                                  >              
1 #I (I4)
END-DEFINE
SET KEY ALL
DEFINE PRINTER (02) OUTPUT 'SOURCE'
EJECT OFF (02)
SET CONTROL 'Z'
*
FOR #I = 1 ##
  WRITE (02) NOTITLE #LDA (#I)
END-FOR
*
CALLNAT 'USR4201N' P-FUNCTION
                   P-FORMAT
                   P-OBJECT-TYPE
                   P-OBJECT-NAME      
                   P-OBJECT-LIBRARY
                   P-LIBRARY-DBID     
                   P-LIBRARY-FNR
                   P-LIBRARY-PASSWORD 
                   P-LIBRARY-CIPHER
                   P-WRITE-ERROR-MODE
                   P-RETURN-CODE      
                   P-RETURN-MESSAGE
                   P-FSEC-DBID        
                   P-FSEC-FNR
                   P-FSEC-PSW         
                   P-FSEC-CIP
IF  P-RETURN-CODE = 0
  THEN
    WRITE 'Function completed successfully.'
  ELSE
    PRINT 'Error occurred:'
        / 'Return code' P-RETURN-CODE
        / 'Error message' P-RETURN-MESSAGE
END-IF
END