2013 Dec 19 10:40 AM
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
2013 Dec 19 1:23 PM
Hello Arbaaz,
Could you try change the type of field for STRING or LCHAR.
2013 Dec 19 10:50 AM
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
2013 Dec 19 12:03 PM
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.
2013 Dec 19 12:42 PM
Arbaaz,
There is something missing at the source end then. Can you please attach the transformation code details.
Regards,
bhaskar
2013 Dec 19 1:09 PM
Hi! Bhaskar,
The structure used is ZST_TR_IN_10_00 :
HED | CHAR | 8 |
HEH | CHAR | 6 |
COLL_CODE | CHAR | 10 |
TRAVEL_LEAD_ID | NUMC | 10 |
TRAVEL_ID | NUMC | 10 |
ORIGIN | CHAR | 1 |
GROUP_CODE | CHAR | 10 |
CONT_PERSON | CHAR | 100 |
OP_BY_AGENCY | CHAR | 1 |
AGENCY | CHAR | 50 |
ROUTE | CHAR | 50 |
DEPARTURE_D | CHAR | 8 |
RETURN_D | CHAR | 8 |
STATUS | CHAR | 1 |
PLAN_REQUEST | CHAR | 1 |
PROJ_SUBSID | CHAR | 250 |
CHILDS_SPONS | CHAR | 250 |
WTWS_SPONS | CHAR | 250 |
SECTOR | CHAR | 250 |
FVF_ACCOMP | CHAR | 100 |
PASS_PICKUP | CHAR | 1 |
PASS_PICKUP_T | CHAR | 10 |
PASS_PICKUP_P | CHAR | 100 |
NUMBER_ROOMS | NUMC | 4 |
DETAILS | CHAR | 1000 |
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.
2013 Dec 20 5:12 AM
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
2013 Dec 19 12:10 PM
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
2013 Dec 19 1:15 PM
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.
2013 Dec 19 1:21 PM
Hello Arbaaz,
What is the exact requirement? What do you want to achieve, can you please explain ?
Regards,
Tanmoy
2013 Dec 19 1:27 PM
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
2013 Dec 19 1:54 PM
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
2013 Dec 19 2:03 PM
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.
2013 Dec 19 2:37 PM
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
2013 Dec 19 2:53 PM
2013 Dec 19 1:21 PM
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.
2013 Dec 19 2:26 PM
Hi! Balaji,
I tried doin that. It does not work instead it gives an error for compatibility.
2013 Dec 19 1:23 PM
Hello Arbaaz,
Could you try change the type of field for STRING or LCHAR.
2013 Dec 19 2:08 PM
2013 Dec 19 2:12 PM
Arbaaz,
This is curious. I will create the structure and transformation here to make some tests and I back to you.
2013 Dec 19 2:18 PM
2013 Dec 19 4:29 PM
2013 Dec 19 6:14 PM
Hey Arbaaz, don`t need the file anymore.
I have created the objects here and tested and my conclusion:
Attention Points:
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:
DATA: gt_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.
2013 Dec 20 6:13 AM
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