ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to convert from java string to 400 alpha?

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

  • How to convert from java string to 400 alpha?

    Java 101,

    How do I convert a java string to a 400 alpha field?

  • #2
    Re: How to convert from java string to 400 alpha?

    Can you give a bit more context to your question? What are you going to do with the 400 alpha field when you get it?

    Comment


    • #3
      Re: How to convert from java string to 400 alpha?

      And where are you going to "convert" it? Is this all to be done in Java? Or is this a value that is passed to some other program? (What program?) Why do you think it's not already a "400 alpha field"? Some additional explanation of the problem would help us know how to answer your question.
      Tom

      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

      Comment


      • #4
        Re: How to convert from java string to 400 alpha?

        Im retrieving data from a web service and I want to write it a DB.

        Thank You very much for all your help. Ive used your RPG "casting" example many times.
        Last edited by davisty; July 13, 2013, 11:22 AM.

        Comment


        • #5
          Re: How to convert from java string to 400 alpha?

          You shouldn't need to convert it before writing it to a DB... the JDBC driver should automaticalyl convert Java strings. Unless you're writing it using some other method?

          Comment


          • #6
            Re: How to convert from java string to 400 alpha?

            Im using RPG to call a java webservice. It's returning a string object. I need to update that string object into an i5 alpha field to display on a cgidev2 browser screen and update it into a DB.

            Comment


            • #7
              Re: How to convert from java string to 400 alpha?

              Web services return data in XML. When you parse the XML on the RPG-side, you will have an alphanumeric string, not a String object. No special conversion should be needed.

              Comment


              • #8
                Re: How to convert from java string to 400 alpha?

                It's a restful service, it's returning a json string that is being parsed in the java program and the java return statement is returning a string

                Comment


                • #9
                  Re: How to convert from java string to 400 alpha?

                  How are you calling the Java program? Via the RUNJVA command? Via JNI (extproc with *java)? Via APIs? Via the Java PCML tools? Another method?

                  Comment


                  • #10
                    Re: How to convert from java string to 400 alpha?

                    Via JNI,


                    C eval mapString =
                    C new_String('sdk_config.properties')
                    C eval oauth = new_OAuthTokenCredential
                    C (clntString: scrtString)
                    C eval json = getAccessToken(oauth)

                    Comment


                    • #11
                      Re: How to convert from java string to 400 alpha?

                      For JNI I would do something like this:
                      Code:
                      D getBytes        pr         32767A   varying            
                      D                                     extproc(*JAVA:     
                      D                                     'java.lang.String':
                      D                                     'getBytes')        
                       ..                                       
                          RpgAlphaVar = getBytes(javaStringObj);

                      Comment


                      • #12
                        Re: How to convert from java string to 400 alpha?

                        Wow, thank you very much Scott.

                        Ive learned alot reading your presentations and open source projects ...

                        Comment

                        Working...
                        X