ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

QSNDDTAQ and QRCVDTAQ in RPGLE

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • QSNDDTAQ and QRCVDTAQ in RPGLE

    Hi,

    I have a file name FILE1. It contains the data. I have to read it record wise and need to send in Data Queue.
    Please let me know how to put data into Queue base on record.

    I know the process like below

    EVAL DATA='we are working in as400'
    eval qdatalen=%len(data)
    call 'qsnddtaq'
    parm qname
    parm qlibrary
    parm qdatalen
    parm data


    But Instead of the text I need to populate as FILE1 record into data field.

    Thanks & Regards,
    Reddi Kumar

  • #2
    Just a question of changing the "data" field reference to a DS containing the record image. Either define a DS using ExtName which will allow it to be populated by the read. Or use LikeRec and then do the read into the DS (Result field I/O).

    Comment


    • #3
      To add a bit of clarity:

      A Data Queue accepts a single long character field. So any data you want to put onto a queue, must first be converted to this format: multiple fields need to be concatenated together, and non-character fields need to be converted to character.

      As JonBoy says, you could do this with a data structure. A physical file can be defined in your F specs for normal IO, and as an external data structure (though it needs a different name). You can use native IO or embedded SQL to read your file record in the normal way, then use any method you like to move it into the data structure, then place the data structure into the Data Queue's data field.

      Although:

      I don't know where this Data Queue is going. But if it is another job on the same system, can that job read FILE1 directly? In which case, instead of sending the whole record, your program could just send the record key, and the receiving program could use that to access the record from FILE1?

      Comment


      • #4
        Originally posted by Vectorspace View Post
        To add a bit of clarity:

        A Data Queue accepts a single long character field. So any data you want to put onto a queue, must first be converted to this format: multiple fields need to be concatenated together, and non-character fields need to be converted to character. ...
        A data queue accepts anything you want to put in it. It doesn't have to be character data. It could be integer, or packed, or anything you like. If you put a data structure onto a data queue, it can have subfields that don't have normal character data, that would look weird if you looked at the data structure as a character string.

        The only thing that matters is that the programs that send and receive the data queue entries have to agree on the format of the data.

        Comment


        • #5
          Sorry, I did not explain very well. I meant to say the data just has to be assembled into one long character field, not that the data has to be character formatted.

          Comment


          • #6
            I want to write file record completely. For example

            SID SNAME
            1001 Reddi Kumar
            1002 Kumar
            1003 Bandaru

            I want to write entire record once.
            record -1001 Reddi Kumar. into Queue.
            I don't want to concatenate all the fields. I want write to Queue as a record.

            Comment


            • #7
              You have to do something so that all the fields that make up the file record are merged together into a single long character field, because that is all that a data queue can handle.

              Define a data area containing the exact same field types/sizes as your file.
              The easiest way is to just import the file as an external data structure

              fixed format:
              D FILE1DS E DS extname('FILE1) qualified

              free format:
              dcl-ds FILE1DS extname('FILE1DS') qualified end-ds;

              Then if you are using native IO or SQL to read the file, read it into that DS:

              native:
              CHAIN key FILE1 FILE1DS;

              SQL:
              select * from FILE1 into FILE1DS where SID = 1234;

              FILE1DS contains the file record. You can put FILE1DS into the data field that you pass to QSNDDTAQ.

              The program that receives the data queue, must define an identical data structure. It can then put the received data into that data structure to decode it

              Comment


              • #8
                Sorry, I clicked Post instead of Preview, and there were errors - which I cannot fix because I do not have the ability to edit my posts.

                The free format DS should be:
                dcl-ds FILE1DS extname('FILE1') qualified end-ds;


                The SQL should be:
                select * from FILE1 into :FILE1DS where SID = 1234;

                Comment


                • #9
                  Depending on what you are trying to do, I like to flush out any possible data decimal errors after I pull a string of characters off the data queue but adding zero to all the numbers in the resulting data structure.

                  Monitor ;
                  OrderQty += 0 ;
                  AllocQty += 0 ;
                  ShipQty =+ 0 ;
                  .. etc
                  On-Error cDataDecErr ; // 907
                  // some number has junk in it
                  EndMon ;

                  Ringer

                  Comment

                  Working...
                  X