Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Simple transformation from XML to ITAB. Field length above char 255 not working.

Former Member
0 Kudos
1,452

Hi! Experts,

I have an  requirement in which I have to do a transformation from an XML file to internal table in which structure has a field of char1000 or string.

I used the transaction XSLT_TOOL and created a Simple transformation with the table type of required structure. But when I call the transform statement the text in the field gets truncated at 255 characters as it is returned in the internal table.

Please guide me how I can overcome this.

Thanks and Regards,

Arbaaz

1 ACCEPTED SOLUTION

Former Member
0 Kudos
551

Hello Arbaaz,

Could you try change the type of field for STRING or LCHAR.

22 REPLIES 22

Former Member
0 Kudos
551

Hi Arbaaz,

in your simple transormation to table type, did you use the field which is of type string or used as char255 ?

Thanks,

bhaskar

0 Kudos
551

Hi! Bhaskar,

Yes the simple transformation is to table type. And I have declared the field as char1000. I also tried with type string but it did not work.

0 Kudos
551

Arbaaz,

There is something missing at the source end then. Can you please attach the transformation code details.

Regards,

bhaskar

0 Kudos
551

Hi! Bhaskar,

The structure used is ZST_TR_IN_10_00 :

HED

CHAR8
HEHCHAR6
COLL_CODECHAR10
TRAVEL_LEAD_IDNUMC10
TRAVEL_IDNUMC10
ORIGINCHAR1
GROUP_CODECHAR10
CONT_PERSONCHAR100
OP_BY_AGENCYCHAR1
AGENCYCHAR50
ROUTECHAR50
DEPARTURE_DCHAR8
RETURN_DCHAR8
STATUSCHAR1
PLAN_REQUESTCHAR1
PROJ_SUBSIDCHAR250
CHILDS_SPONSCHAR250
WTWS_SPONSCHAR250
SECTORCHAR250
FVF_ACCOMPCHAR100
PASS_PICKUPCHAR1
PASS_PICKUP_TCHAR10
PASS_PICKUP_PCHAR100
NUMBER_ROOMSNUMC4
DETAILSCHAR1000

The transformation :

<?sap.transform simple?>

<?sap.transform simple?>

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined">

  <tt:root name="NewDataSet" type="ddic:ZTT_TR_IN_10_00"/>

  <tt:template>

    <NewDataSet>

      <tt:loop ref=".NewDataSet">

        <ZCRM_IN_10_00>

          <HED tt:value-ref="HED"/>

          <HEH tt:value-ref="HEH"/>

          <COLL_CODE tt:value-ref="COLL_CODE"/>

          <TRAVEL_LEAD_ID tt:value-ref="TRAVEL_LEAD_ID"/>

          <TRAVEL_ID tt:value-ref="TRAVEL_ID"/>

          <ORIGIN tt:value-ref="ORIGIN"/>

          <GROUP_CODE tt:value-ref="GROUP_CODE"/>

          <CONT_PERSON tt:value-ref="CONT_PERSON"/>

          <OP_BY_AGENCY tt:value-ref="OP_BY_AGENCY"/>

          <AGENCY tt:value-ref="AGENCY"/>

          <ROUTE tt:value-ref="ROUTE"/>

          <DEPARTURE_D tt:value-ref="DEPARTURE_D"/>

          <RETURN_D tt:value-ref="RETURN_D"/>

          <STATUS tt:value-ref="STATUS"/>

          <PLAN_REQUEST tt:value-ref="PLAN_REQUEST"/>

          <PROJ_SUBSID tt:value-ref="PROJ_SUBSID"/>

          <CHILDS_SPONS tt:value-ref="CHILDS_SPONS"/>

          <WTWS_SPONS tt:value-ref="WTWS_SPONS"/>

          <SECTOR tt:value-ref="SECTOR"/>

          <FVF_ACCOMP tt:value-ref="FVF_ACCOMP"/>

          <PASS_PICKUP tt:value-ref="PASS_PICKUP"/>

          <PASS_PICKUP_T tt:value-ref="PASS_PICKUP_T"/>

          <PASS_PICKUP_P tt:value-ref="PASS_PICKUP_P"/>

          <NUMBER_ROOMS tt:value-ref="NUMBER_ROOMS"/>

          <DETAILS tt:value-ref="DETAILS"/>

        </ZCRM_IN_10_00>

      </tt:loop>

    </NewDataSet>

  </tt:template>

</tt:transform>

Please check if you can figure out something from this.

Thanks.

0 Kudos
551

Arbaaz,

your details field is getting truncated. where you see it in output or in debugging ?

As renon mentioned, in debugger we can see upto 255charecters only.

Regards,

Bhaskar

former_member196098
Participant
0 Kudos
551

Bhaskar

xslt_tool strans is hard for first time users

if your xml is complicated then use not the simple one but the xslt transformation

and you can use tool like Altova for that

i needed to use that and it saved me lots of time

if your xml is simple then

seems like the xml is getting confused in mapping

!!go to xslt_tool and see the  button edit the transformation graphically!!

There you can see individual elements and see the length or type is assıgned

have a look hope helps

0 Kudos
551

Hi! Solen,

Once I create the transformation I am unable to edit using 'Edit transformation graphically'. It gives me a message Namespace prefix "" is not defined.

So i created a new one, and found that the length of the datatype is not shown only the index is shown.

Former Member
0 Kudos
551


Hello Arbaaz,

What is the exact requirement? What do you want to achieve, can you please explain ?

Regards,

Tanmoy

0 Kudos
551

Hi! Tanmoy,

An XML file needs to be imported into the system and mapped on the tables. The XML file has an field with 'Details'.

A program was already made and was working and details was of 255 characters in it, but now we need this details to be about 1000 characters.

The transformation fro the same is not working

0 Kudos
551

Why don't you break down the structures to a more granular level accomodating several fields for just one 'Details' field. Can you use detail-1, detail-2;etc instead of a single detail field. Is it possible to do so?

Regards,

Tanmoy

0 Kudos
551

Dear Tanmoy,

The XML cannot be edited by me a it is coming from outer source. I can split the fields but for that XML has to be read with the complete field.

0 Kudos
551

Ok got your point!

I assume that the source XML field 'Details' is also of 1000 characters & when you are trying to map it to the field in the internal table it is truncated to 255 characters even if you are having a field in the internal table defined as 1000 characters; right?

Regards,

Tanmoy

0 Kudos
551

Exactly. Truncation during transformation

0 Kudos
551

Hi Arbaaz,

  In the Internal table structure try to give the data element as "RAW STRING" instead of string.

for e.g

types : begin of ty_test,

             attr type raw string,

           end of ty_test.

Data: it_test type standard table of ty_test.

Regards,

S.Balaji.

0 Kudos
551

Hi! Balaji,

I tried doin that. It does not work instead it gives an error for compatibility.

Former Member
0 Kudos
552

Hello Arbaaz,

Could you try change the type of field for STRING or LCHAR.

0 Kudos
551

Hi! renan,

I tried doin that. It does not work

0 Kudos
551

Arbaaz,

This is curious. I will create the structure and transformation here to make some tests and I back to you.

0 Kudos
551

Ok! Renan, I'll be waiting for you reply.Thanks

0 Kudos
551

Could you send me the file for my tests?

0 Kudos
551

Hey Arbaaz, don`t need the file anymore.

I have created the objects here and tested and my conclusion:

  • With CHAR field not will work
  • With STRING field will work

Attention Points:

  • Debugger Limit to only 255 caracters but you can see what is the real size

I have created a file with 460 positions in field detail and the program reads entire field by simple transformation:

Picture 1: My file

Picture 2: Debugger Screen

Picture 3: Structure Detail

My program code:

DATAgt_file_xml   TYPE STANDARD TABLE OF string,

       ls_file_xml   LIKE LINE OF gt_file_xml,

       gv_xml_string TYPE string.


DATA: gt_xml TYPE ztt_tr_in_10_00,

      ls_xml LIKE LINE OF gt_xml.

START-OF-SELECTION.

*  Subroutine to read the file

   PERFORM read_local_file USING p_path

                           CHANGING gt_file_xml.

   LOOP AT gt_file_xml INTO ls_file_xml.

     CONCATENATE gv_xml_string

                 ls_file_xml

            INTO gv_xml_string.

   ENDLOOP.

   CALL TRANSFORMATION z_test_sdn

     SOURCE XML

       gv_xml_string

     RESULT

       newdataset = gt_xml.

Transformation:

<?sap.transform simple?>

<?sap.transform simple?>

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined">

   <tt:root name="NewDataSet" type="ddic:ZTT_TR_IN_10_00"/>

   <tt:template>

     <NewDataSet>

       <tt:loop ref=".NewDataSet">

         <ZCRM_IN_10_00>

           <HED tt:value-ref="HED"/>

           <HEH tt:value-ref="HEH"/>

           <COLL_CODE tt:value-ref="COLL_CODE"/>

           <TRAVEL_LEAD_ID tt:value-ref="TRAVEL_LEAD_ID"/>

           <TRAVEL_ID tt:value-ref="TRAVEL_ID"/>

           <ORIGIN tt:value-ref="ORIGIN"/>

           <GROUP_CODE tt:value-ref="GROUP_CODE"/>

           <CONT_PERSON tt:value-ref="CONT_PERSON"/>

           <OP_BY_AGENCY tt:value-ref="OP_BY_AGENCY"/>

           <AGENCY tt:value-ref="AGENCY"/>

           <ROUTE tt:value-ref="ROUTE"/>

           <DEPARTURE_D tt:value-ref="DEPARTURE_D"/>

           <RETURN_D tt:value-ref="RETURN_D"/>

           <STATUS tt:value-ref="STATUS"/>

           <PLAN_REQUEST tt:value-ref="PLAN_REQUEST"/>

           <PROJ_SUBSID tt:value-ref="PROJ_SUBSID"/>

           <CHILDS_SPONS tt:value-ref="CHILDS_SPONS"/>

           <WTWS_SPONS tt:value-ref="WTWS_SPONS"/>

           <SECTOR tt:value-ref="SECTOR"/>

           <FVF_ACCOMP tt:value-ref="FVF_ACCOMP"/>

           <PASS_PICKUP tt:value-ref="PASS_PICKUP"/>

           <PASS_PICKUP_T tt:value-ref="PASS_PICKUP_T"/>

           <PASS_PICKUP_P tt:value-ref="PASS_PICKUP_P"/>

           <NUMBER_ROOMS tt:value-ref="NUMBER_ROOMS"/>

           <DETAILS tt:value-ref="DETAILS"/>

         </ZCRM_IN_10_00>

       </tt:loop>

     </NewDataSet>

   </tt:template>

</tt:transform>

Try again and check the string size in debugger.

0 Kudos
551

Dear Renon,

Thank you so much. The problem is solved. You were right it does not show in the debugger more then 255 characters.

The thing what confused me the most was even in the database table it showed only 255 characters and I didn't have a clue that longer text exist there.

The same is true when we try to print the such long text directly on the screen. It does not print the whole text. We have to divide it into smaller strings.

Thank & Regards,

Arbaaz