Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Data Queue control: TransferData method - keyed...

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

  • Data Queue control: TransferData method - keyed...

    Alright - if you use this method for non-keyed data queues on the 400, it is simple enough. But what's the trick for using it for keyed data queues? My problem all comes down to this statement -- lngReturn = TestDQ.TransferData(DTAQKey, DTAQKeyLen) producing an error code 4011 through the lngReturn variable (cwbInvalidAPIParameter), which I gather is a result of the contents of the DTAQKey parm. It's supposed to of type Byte. How do I convert a 10 character userid field to a field of type Byte?

  • #2
    Data Queue control: TransferData method - keyed...

    Problem partially resolved. I think. I searched one of the VB/A forums and discovered the StrConv() function... DTAQKey = StrConv(DTAQKeyString, vbFromUnicode) Now, I connect to the AS/400 and read the data queue. Next problem -- I get the 6012 return code (cwbdqBadKeyLength). The notes from the TransferData method help text states -- " If the TransferType is cwbdqReceive, this parameter points to the length of the key value used to determine which record to retrieve." Duh-fu?

    Comment


    • #3
      Data Queue control: TransferData method - keyed...

      Joe, Maybe this will help. Here is the code listing from IBM's example on how to receive data from a dataq (this is in the Program FilesIBMCLIENT ACCESSTOOLKITSAMPLESVBASICCA400DQRMTCMD folder):
       Private Sub Command3_Click() Dim rc As Long Dim keyLength As Integer Dim errorcount As Long Dim errorText As String Screen.MousePointer = 11 rc = receiveDQ.TransferData(Null, keyLength) ' Note: If you have Client Access Version 3 Release 1 Modification 3 or ' greater and you are not accessing a keyed data queue (like above), ' you could replace the previous call with: ' ' rc = receiveDQ.TransferTextData() Screen.MousePointer = 0 If (rc <> cwbOK) Then errorcount = receiveDQ.GetErrorMessageCount If (errorcount <> 0) Then For x = 1 To errorcount Call receiveDQ.GetErrorMessageText(x, errorText) MsgBox (errorText) Next x Else MsgBox (rc) End If Else MsgBox ("Data received successfully") End If End Sub 
      Does this help? Bill

      Comment


      • #4
        Data Queue control: TransferData method - keyed...

        Negative. But thank you for doing the research. The problem with the example code is that it is for a non-keyed data queue. With a non-keyed data queue, you specify Null for the key (like below): rc = receiveDQ.TransferData(Null, keyLength)

        Comment


        • #5
          Data Queue control: TransferData method - keyed...

          Joe, OK, try this:
           Considerations When Using Keyed Data Queues The key value of a data queue is not affected by the translation setting. Keys can be any binary value. If you are using text characters as keys, you must translate the data using the cwbNL APIs. You should always use the BYTE data type with keys. See common visual basic programming errors for information on the STRING and BYTE data types. Example: Dim retVal As Long Dim keyVal(5) As Byte Dim keyLength As Integer 'EBCDIC "012345" keyVal(0) = &HF0 keyVal(1) = &HF1 keyVal(2) = &HF2 keyVal(3) = &HF3 keyVal(4) = &HF4 keyVal(5) = &HF5 keyLength = UBound(keyVal) retVal = myKeyedDataQueue.TransferData(keyVal, keyLength) 
          This was found at: http://as400service.rochester.ibm.co...d46f758625680b 00020373/def5574d27de318e862565c2007cbc3c?OpenDocument&Highlight=2,transferdata Looks like you have to translate the key into EBCDIC from ASCII first, then load the key into a Byte Array. BUT, I just tried this and am getting the same error you are, so . . . Bill

          Comment


          • #6
            Data Queue control: TransferData method - keyed...

            Thanks. I saw that. How would you convert a alpha characters, though? like a-z, or A-Z. The other thing that I'm wondering about is the property = DataQueue.ConvertData = True. If you set it so, I thought that you wouldn't have to the fancy conversion, as in the example...

            Comment


            • #7
              Data Queue control: TransferData method - keyed...

              I think that I answered my own questions -- How would you convert a alpha characters, though? like a-z, or A-Z. Brute force, for testing purposes. The other thing that I'm wondering about is the property = DataQueue.ConvertData = True. On a retrieve, ConvertData converts the incoming EBCDIC to ASCII. *** *** *** After using IBM's example, I don't get a 6012 return code, I get a 6017 return code (cwbdqTimedOut). Why?

              Comment


              • #8
                Data Queue control: TransferData method - keyed...

                Joe, Well, you got much further than I did. I tried modifying the code in the Samples Folder to match what they suggested for a keyed dtaq, but I still would get the 6012. On the webpage I referenced earlier, there is another sample program you can download. This program seems to be a sample of everything you would need to do to a dtaq, it looked pretty comprehensive. Bill

                Comment


                • #9
                  Data Queue control: TransferData method - keyed...

                  __Keyed data queue__ Since the information in non-keyed data queues can be accessed by anyone, I made mine keyed, making the key a combination of the AS/400 userid and the sequence number of the message; i.e. -- JKOONTZ001 JKOONTZ002 On the PC, I'm extracting the user profile, and converting it to all caps (to match the AS/400). *** *** *** __6017 return code (cwbdqTimedOut)__ To match what we do on the AS/400, I'm code into the PC that I want to access data queue records where the keys are greater than or equal to JKOONTZ. I get the time-out because this key is not found in my data queue. Once, I change the key to something like JKOONTZ001, I grab a record from the data queue. But that's the only record I grab from the data queue. I note that if I change the key to JKOONTZ002, then I gran the next record in the data queue. I shouldn't have to do that, should I? I thought I could set a lower limit -- type deal, and read from there until the key does not match JKOONTZ. *** *** *** You're time out problem. I downloaded the latest service pack for Client Access Express. I noted that the readme says that the service pack cured some data queue access problems. I believe that they were related to Windows NT SP 5 usage, which is what I unfortunately have. I can't sware to that being the cure, but it worked. The other thing about the 6012 error -- try making the keylength -- keylength = Ubound(bytekey) + 1.

                  Comment


                  • #10
                    Data Queue control: TransferData method - keyed...

                    Joe, I shouldn't have to do that, should I? I thought I could set a lower limit -- type deal, and read from there until the key does not match JKOONTZ. I think in this case, you should consider the phrase KEY to be literally a KEY and not an access method. It will fit any door with the corresponding value and that's it. So, for your circumstance, every key entry should be the user name and then there should be a sequential field in the data to help you delineate the entries. Bill

                    Comment


                    • #11
                      Data Queue control: TransferData method - keyed...

                      Bill> "So, for your circumstance, every key entry should be the user name and then there should be a sequential field in the data to help you delineate the entries." Thanks. Considering that, I changed the statement -- TestDQ.KeyComparisonType = cwbdqGtOrEqual - to - TestDQ.KeyComparisonType = cwbdqEqual And performed this read in a loop -- lngReturn = TestDQ.TransferData(DTAQKey, DTAQKeyLen) until the lngReturn value is not zero or the loop reaches an abnormal count.

                      Comment

                      Working...
                      X