ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

RPG program with Foreign letters as parameters - Help needed

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

  • RPG program with Foreign letters as parameters - Help needed

    Hi all,
    I am trying to call an RPG program with an input parameter from Tibco API. TIBCO passes a JSON data as a parameter to this RPG program and this JSON data has some foreign letters in it. My RPG is not receiving this foreign letters properly and so, the program fails with reason as "Invalid character string". I have tried defining the parameter variable in RPG as Varchar or Varucs2 or Varchar with utf-8. But no luck. Even I tried changing the service job in as400 thats initiated by Tibco to CCSID 875 (Greece), but its not working. Could anyone please help on this.

  • #2
    Is your program working correctly when there are no special characters?

    What are the first say 20 bytes of the parameter that you are receiving from the API? In debug, EVAL the parameter with :x
    Code:
    ===> eval myparm:x 20
    And what are the first 10 or 20 characters of the value that is being passed from the API? I mean what is the actual text, such as "abcde"?

    Comment


    • #3
      Hi Barbara,
      Thank you for your help. Yes, my program is working fine when there no special characters.

      The first 2o characters passed from TIBCO API to RPG variable are all alpha characters and when I do the eval myparm:x 20, below is the result I got.

      00000 000002E1 C07F8396 94978195 A8C39684
      00010 857F7A7F C1E4E2E3 7F6B7F83 9396A484

      The Greek letters are present in the middle of the parameter(not on first 20 characters). When i do the eval myparm, below is the result i got for the Greek letter position. Please refer the ones in bold letters below.

      00150 A285D699 8485997F 7A7F3F3F 3F3F3F7F

      Thank you.

      Comment


      • #4
        The variable contains EBCDIC

        Code:
        A2 85 D6 99 84 85 99 7F 7A 7F 3F 3F 3F 3F 3F 7F
         s  e  O  r  d  e  r  "  :  "                 "
        3F was substituted for the untranslatable characters. Can you post the code? The field/parm definitions probably need to change.

        Comment


        • #5
          Thank you for the help. Below is the code am trying in RPG. Here the "wkinput" is the work variable that receives the JSON data from external like postman via Tibco API. After receiving the value from external, I am moving the value to "Wktemp" and Null terminate it and then trying to parse in yajl_tree_parse.

          Instead of receiving the value from external, If I hardcode the wkinput like "wkinput= '{"city": "abcde", "citycode": "Παραδ" }';", the program is working fine without any issues. The issue is only when i get the input parameter from outside like postman via tibco API, the input value received is as mentioned in previous post above and it is failing.

          dcl-s wkinput varchar(99999:4) ccsid(*utf8) inz;
          dcl-s wktemp varchar(99999:4) ccsid(*utf8) inz;
          dcl-s errMsgBuf char(500);

          wktemp = %trimr(wkinput);
          wktemp += x'00';
          docnode = yajl_tree_parse( %addr(wktemp:*DATA)
          : errMsgBuf
          : %size(errMsgBuf));

          Comment


          • #6
            How does wkinput get populated?

            Comment


            • #7
              As USERNAME10 said, the value is EBCDIC, so you can't define it with CCSID(*UTF8).

              The first 4 bytes are the "length", so the data is varying-length with a 4-byte prefix. So the varchar(99999:4) part of your definition is correct.

              If the parameter you are being passed already contains the x'3F' characters, then the problem is not in your program. It is in your caller. The Greek characters have already been replaced by x'3F' before the parameter gets to your program.

              Comment

              Working...
              X