<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Convert structure to char field in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489740#M16428</link>
    <description>&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;You can try class CL_ABAP_STRUCTDESCR for getting structure fields and then check for fields type P whether they CURR or QUAN via class CL_ABAP_TYPEDESCR.&lt;/P&gt;&lt;P&gt;Also if you know exactly the fields and their currency\unit keys, you can just set them via WRITE statement&lt;/P&gt;&lt;P&gt;Hope it's helpful.&lt;/P&gt;&lt;P&gt;Evgeny&lt;/P&gt;</description>
    <pubDate>Mon, 29 May 2017 14:28:37 GMT</pubDate>
    <dc:creator>former_member400468</dc:creator>
    <dc:date>2017-05-29T14:28:37Z</dc:date>
    <item>
      <title>Convert structure to char field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489739#M16427</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I am trying to convert a structure (ls_bt_i) into a charfield (ls_idoc_dd-sdata):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  FIELD-SYMBOLS:
    &amp;lt;ls_bt_i&amp;gt; TYPE c,
    &amp;lt;ls_bt_c&amp;gt; TYPE c.


* Generate Idoc Data-Record(s) - Item Segment
  lt_items[] = items.

  LOOP AT lt_items INTO ls_items.
    PERFORM data_segment_create CHANGING lv_segnum.
    PERFORM idoc_data_record_create USING gc_seg_i lv_psgnum CHANGING lv_segnum ls_idoc_dd.

    MOVE-CORRESPONDING ls_items TO ls_bt_i.
    ASSIGN ls_bt_i TO &amp;lt;ls_bt_i&amp;gt; CASTING.
    ls_idoc_dd-sdata = &amp;lt;ls_bt_i&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It works fine with the char components of the structure, but there is a quantitiy and an amount field in the structure too and their values are in char something like #### (prob. the hex value).&lt;/P&gt;&lt;P&gt;So my question is howw can i convert the structure into the char without messing my quantity and amount fields up?&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 13:49:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489739#M16427</guid>
      <dc:creator>BjrnKorioth</dc:creator>
      <dc:date>2017-05-29T13:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Convert structure to char field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489740#M16428</link>
      <description>&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;You can try class CL_ABAP_STRUCTDESCR for getting structure fields and then check for fields type P whether they CURR or QUAN via class CL_ABAP_TYPEDESCR.&lt;/P&gt;&lt;P&gt;Also if you know exactly the fields and their currency\unit keys, you can just set them via WRITE statement&lt;/P&gt;&lt;P&gt;Hope it's helpful.&lt;/P&gt;&lt;P&gt;Evgeny&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 14:28:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489740#M16428</guid>
      <dc:creator>former_member400468</dc:creator>
      <dc:date>2017-05-29T14:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Convert structure to char field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489741#M16429</link>
      <description>&lt;P&gt;Depending on what you want to do (storage or transfer and not user interaction) CL_ABAP_CONTAINER_UTILITIES might also help.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 15:58:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489741#M16429</guid>
      <dc:creator>fabianlupa</dc:creator>
      <dc:date>2017-05-29T15:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Convert structure to char field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489742#M16430</link>
      <description>&lt;P&gt;This one should be easy if you follow the traditional way. I assume ls_items and ls_bt_i shares similar data type declarations. Since you have used move corresponding, your source QTY of ls_items will be moved to ls_bt_i QTY field. My suggestion would be, if you are already aware of ls_items structure, then change your ls_bt_i structure to hold only Characters (Flat type I mean). &lt;/P&gt;&lt;P&gt;For Ex: Lets assume ls_items is having FKIMG as data type for QTY, then corresponding to this field, declare your ls_bt_i structure QTY field as FKIMG(17) type C. Since your ls_bt_i structure is of flat type, you don't need the declared field symbols (&amp;lt;ls_bt_i&amp;gt;). After move corresponding, just condense (optional) the qty field and assign it to sdata. This should be simple and solve your issue.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;MOVE-CORRESPONDING ls_items TO ls_bt_i.
CONDENSE ls_bt_i-fkimg.
ls_idoc_dd-sdata = ls_bt_i.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF typ_item,
         vbeln  TYPE vbeln,
         fkimg  TYPE fkimg,
       END OF typ_item,

       BEGIN OF typ_data,
         vbeln(10) TYPE c,
         fkimg(17) TYPE c,
       END OF typ_data.

DATA: ls_items TYPE typ_item,
      ls_bt_i  TYPE typ_data,
      ls_sdata TYPE char1024.

ls_items-vbeln = '0000100000'.
ls_items-fkimg = '1000.00'.
MOVE-CORRESPONDING ls_items TO ls_bt_i.
CONDENSE ls_bt_i-fkimg.
ls_sdata = ls_bt_i.
WRITE:/ ls_sdata.

Output is: 00001000001000.000
Without Condense : 0000100000        1000.000&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 May 2017 18:47:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489742#M16430</guid>
      <dc:creator>rmnachi_kx</dc:creator>
      <dc:date>2017-05-29T18:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert structure to char field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489743#M16431</link>
      <description>&lt;P&gt;And Why is this happening ?&lt;/P&gt;&lt;P&gt;Because numeric information is stored in a variety of formats that are not human readable such ad BCD or Mantissa/Exponent for floating points.  When you move a structure to a string,  then the structure is treated as a single long string which does not respect the individual field types so you then get the binary representations of the number as a string which are generally unprintable characters displayed as '#'.&lt;/P&gt;&lt;P&gt;As an aside you could (before Unicode) emulate the CHR() and ASC() functions of other languages using a structure:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Data: Begin Of Chr,
            Asc type x,
      End Of Chr.
*
Chr-Asc = 65.
Write :/ Chr.          " = 'A'
*
Chr = 'B'.
Write :/ Chr-Asc.      " = 66.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This occurs in a lot of languages because the only way to treat a structure as a single piece of data is a string.&lt;/P&gt;&lt;P&gt;Rich&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 12:43:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/convert-structure-to-char-field/m-p/489743#M16431</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-05-30T12:43:20Z</dc:date>
    </item>
  </channel>
</rss>

