[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WSDL2RPG : Empty tag for decimal variables



You did it right. But you may also consider to do it this way:

Let us assume that you had the following reference data structure that is 
used to define your request message:

D curZualBapiacap09_A2_t...
D               DS               qualified   based(pDummy)
D  aNillableA             128A
D  aNillableI              10I 0


D curZualBapiacap09_A2...
D               DS               likeds(curZualBapiacap09_A2_t)
D                                inz


The code producing the request message my look similar to this:

       '<aNillableA>' +
       Marshaller_toString(
          curZualBapiacap09_A2.aNillableA
          ) +
       '</aNillableA>' +
       '<aNillableI>' +
       Marshaller_toInteger(
          curZualBapiacap09_A2.aNillableI
          ) +
       '</aNillableI>' +

Now you may change your code as shown below to add the null indicators:

D curZualBapiacap09_A2_t...
D               DS               qualified
D  aNillableA             128A   inz
D  aNillableA_isNull
D                            N   inz(*ON)
D  aNillableI              10I 0 inz
D  aNillableI_isNull
D                            N   inz(*ON)

And eventually change the code to produce the request message as shown here:

       '<aNillableA>';
    if (not curZualBapiacap09_A2.aNillableA_isNull);
       request = request +
       Marshaller_toString(
          curZualBapiacap09_A2.aNillableA
          );
    endif;
       request = request +
       '</aNillableA>' +
       '<aNillableI>';
    if (not curZualBapiacap09_A2.aNillableI_isNull);
       Marshaller_toInteger(
          curZualBapiacap09_A2.aNillableI
          );
    endif;
       request = request +
       '</aNillableI>' +

If a value is marked as NULL the resulting XML would look like this:

       <aNillableA></aNillableA>

or

       <aNillableI></aNillableI>

However before setting the values of the request message you had to reset 
the data structure in order to set the NULL indicators to *ON:

    reset curZualBapiacap09_A2;

    curZualBapiacap09_A2aNillableA = 'Hello';
    curZualBapiacap09_A2_isNull = *OFF;

Worth a try?

Please have in mind that I put together the sample at home. I did not yet 
try it in reality.

Thomas.

Am 25.08.2011 08:59, schrieb Dhanushka Manjula:
>
>     Hi Thomas,
>     Thank you in advance for your input.
>     I have only 3 fields to be omitted&  those 3 variables can be
>     permanently removed from client end and host service cannot be changed
>     as well.
>     So I changed STUB with search&  replace function
>     correct me if I'm wrong..
>     I search '<DsctDays1>0.00</DsctDays1>' string in request variable&
>     replace it with '<DsctDays1/>'
>      '<Pmtmthsupl>' +
>      Marshaller_toString(
>         curZualBapiacap09_A2.Pmtmthsupl
>         ) +
>      '</Pmtmthsupl>' +
>      '</item>' +
>         '';
>
>        Search_word   = '<DsctDays1>0.00</DsctDays1>';
>        replace_word  = '<DsctDays1/>'               ;
>        request = SearchR(request:search_word:replace_word);
>     Looks like everything is OK for me..... (temporarily of cause)
>     btw, I think this method is much smarter than 1st one, cause once we
>     need to omit a variable, Just only have to turn *On the indicator.
>     [cid:330@goomoji.gmail]
>        request.myNillableField.isNull = *ON;
>     Thanks again.
>
>     On Thu, Aug 25, 2011 at 1:17 AM, Thomas Raddatz
>     <[1]thomas.raddatz@xxxxxxxxxxx>  wrote:
>
>       The problem you have is a common problem with RPG because RPG does
>       not
>       really support NULL values.
>       Leaving an XML element empty is one option to specify a NULL value
>       in an
>       XML document. But since RPG does not support NULL values, WSDL2RPG
>       does not
>       have a chance to properly recognize NULL values. For strings you
>       may say
>       that a string value with length=0 is equal to NULL. Although that
>       is not
>       really true it should work in most cases. Fine.
>       But for all other field types it is not that easy to define a
>       substitution
>       value for NULL. For example you may say that for numeric fields the
>       substitute for NULL is 0. But is that really a good idea? I do not
>       think
>       so. But what other value should we consider to be equal to NULL?
>       *LOVAL or
>       *HIVAL? Bad.
>       I wished RPG had true NULL support. All you can do now is to say:
>       "For me,
>       0 is equal to NULL" and then modify the generated stub accordingly.
>       I have been thinking about how to support NULL values since the day
>       WSDL2RPG was born. If it wasn't that ugly I would add a NULL
>       indicator
>       field for each nillable field. If the NULL indicator is TRUE the
>       field
>       would be treated as NULL regardless of its actual value. Honestly I
>       do not
>       like that solution because you always have to set two fields for
>       one value,
>       for example:
>          request.myNillableField.value = 123;
>          request.myNillableField.isNull = *OFF;
>       Or in case of a NULL value:
>          request.myNillableField.isNull = *ON;
>       Any other ideas how to solve that problem?
>       Thomas.
>       Am [2]24.08.2011 18:41, schrieb Dhanushka Manjula:
>       >
>       >      Hi All,
>       >      In my RPG code, I have leave out 5 line due to I dont have
>       values to
>
>     >      send, I need closed/empty tag for those
>     >
>     >      //newZualBapiacap09_A2.BlineDate =;
>     >      //newZualBapiacap09_A2.DsctDays1 = 0;
>     >      //newZualBapiacap09_A2.DsctDays2 = 0;
>     >      //newZualBapiacap09_A2.Netterms = 0;
>     >        newZualBapiacap09_A2.PymtMeth  = PYMDDL      ;
>     >      //newZualBapiacap09_A2.Pmtmthsupl = ;
>     >
>     >      Following is the part of SOAP message
>     >
>     >      <BlineDate/>
>     >      <DsctDays1>0.00</DsctDays1>
>     >      <DsctDays2>0.00</DsctDays2>
>     >      <Netterms>0.00</Netterms>
>     >      <PymtMeth>   NP</PymtMeth>
>     >      <Pmtmthsupl/>
>     >
>     >      For String variables, it generates closed tag accordingly but
>     for the
>     >      decimal variables it assigns 0.00 Which were not expected
>     >      How to have a closed/empty tag for decimal variables?
>     >      Thanks
>     >
>     >
>     >
>     >
>
>       >
>       -------------------------------------------------------------------
>       ----
>       >  This is the FTPAPI mailing list.  To unsubscribe, please go to:
>       >  [3]http://www.scottklement.com/mailman/listinfo/ftpapi
>       >
>       -------------------------------------------------------------------
>       ----
>       -------------------------------------------------------------------
>       ----
>       This is the FTPAPI mailing list.  To unsubscribe, please go to:
>       [4]http://www.scottklement.com/mailman/listinfo/ftpapi
>       -------------------------------------------------------------------
>       ----
>
> References
>
>     1. mailto:thomas.raddatz@xxxxxxxxxxx
>     2. tel:24.08.2011%2018
>     3. http://www.scottklement.com/mailman/listinfo/ftpapi
>     4. http://www.scottklement.com/mailman/listinfo/ftpapi
>
>
>
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------