<?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: Type casting error in a Function Module in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/type-casting-error-in-a-function-module/m-p/1710802#M310927</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the data types like typ_s_ressource are defined.&lt;/P&gt;&lt;P&gt;they are declared in the include LZTPGTOP.&lt;/P&gt;&lt;P&gt;The declaration of typ_s_ressource is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of typ_s_ressource,&lt;/P&gt;&lt;P&gt;        perno type hrsobid-sobid,&lt;/P&gt;&lt;P&gt;        org_unit type objid,&lt;/P&gt;&lt;P&gt;        position type hrsobid-sobid,&lt;/P&gt;&lt;P&gt;        leadpos type c,&lt;/P&gt;&lt;P&gt;       end of typ_s_ressource.&lt;/P&gt;&lt;P&gt;If u have any questions, you can ask me, but try to provide a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Srinivas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Nov 2006 12:02:46 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-02T12:02:46Z</dc:date>
    <item>
      <title>Type casting error in a Function Module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/type-casting-error-in-a-function-module/m-p/1710800#M310925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please go thru the following function module which will take the &amp;lt;b&amp;gt;costcenter&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;filename&amp;lt;/b&amp;gt;  as input and will create an XML file in the location specified with the parameter &amp;lt;b&amp;gt;filename .&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried with the following input values and got a type casting error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input values:  Cost centre  : &amp;#145;*&amp;#146;&lt;/P&gt;&lt;P&gt;               File Name    : &amp;#145;c:\Temp\Employee.xml&amp;#146;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FUNCTION z_tpg_employee_orgunit_xml.&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;"Local Interface:&lt;/P&gt;&lt;P&gt;*"  IMPORTING&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"     VALUE(I_COSTCENTER) LIKE  BAPIEMPLB-COSTCENTER DEFAULT '&lt;/STRONG&gt;'&lt;/P&gt;&lt;P&gt;*"     VALUE(I_FILENAME) TYPE  STRING&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Data declaration&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Structures and internal tables&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  data ls_ressource       TYPE typ_s_ressource.&lt;/P&gt;&lt;P&gt;  data lt_ressource       TYPE typ_t_ressource.&lt;/P&gt;&lt;P&gt;  DATA lt_personal_data   TYPE TABLE OF bapip0002b.&lt;/P&gt;&lt;P&gt;  DATA ls_personal_data   LIKE bapip0002b.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA lt_root_objects    TYPE TABLE OF hrrootob.&lt;/P&gt;&lt;P&gt;  data lt_root_tab        TYPE TABLE OF gdstr.&lt;/P&gt;&lt;P&gt;  data ls_root_objects    TYPE hrrootob.&lt;/P&gt;&lt;P&gt;  data ls_root_tab        TYPE gdstr.&lt;/P&gt;&lt;P&gt;  data ls_entry           TYPE struc.&lt;/P&gt;&lt;P&gt;  data ls_object          TYPE objec.&lt;/P&gt;&lt;P&gt;  data ls_root            TYPE gdstr.                    "#EC NEEDED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA lt_orgunits        TYPE TABLE OF typ_s_org.&lt;/P&gt;&lt;P&gt;  DATA ls_orgunits        TYPE          typ_s_org.&lt;/P&gt;&lt;P&gt;  DATA lt_communication   TYPE typ_t_communication.&lt;/P&gt;&lt;P&gt;  DATA lt_orgassignment   TYPE TABLE OF bapip0001b.&lt;/P&gt;&lt;P&gt;  DATA ls_orgassignment   TYPE bapip0001b.&lt;/P&gt;&lt;P&gt;  DATA lt_rate            TYPE typ_t_rate.&lt;/P&gt;&lt;P&gt;  DATA ls_rate            TYPE typ_s_rate.&lt;/P&gt;&lt;P&gt;  DATA ls_ppwla           TYPE pbwla.&lt;/P&gt;&lt;P&gt;  DATA lt_ppwla           TYPE TABLE OF pbwla.&lt;/P&gt;&lt;P&gt;  DATA ls_i0007           TYPE p0007.&lt;/P&gt;&lt;P&gt;  DATA ls_return_0007     TYPE bapiret1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Local helpfields&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  DATA lf_plvar           LIKE objec-plvar.&lt;/P&gt;&lt;P&gt;  data lf_contr_block_nr  TYPE hrrhas-cb_nr.&lt;/P&gt;&lt;P&gt;  data lf_lines           TYPE sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA lf_begda           TYPE sy-datum.&lt;/P&gt;&lt;P&gt;  DATA lf_endda           TYPE sy-datum.&lt;/P&gt;&lt;P&gt;  DATA lf_return_code     TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Infotype structures&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  INFOTYPES 0008.&lt;/P&gt;&lt;P&gt;  INFOTYPES 0007.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Field Symbols&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  FIELD-SYMBOLS: &amp;lt;ls_ressource&amp;gt; TYPE typ_s_ressource.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="---------" /&gt;Start of function routine -&lt;HR originaltext="------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR gf_parent.&lt;/P&gt;&lt;P&gt;  REFRESH gt_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;get current plan&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'RH_GET_PLVAR'&lt;/P&gt;&lt;P&gt;       IMPORTING&lt;/P&gt;&lt;P&gt;            plvar = lf_plvar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if sy-subrc ne 0.&lt;/P&gt;&lt;P&gt;    lf_plvar = '01'.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;get personal data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'BAPI_EMPLOYEE_GETDATA'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            costcenter     = i_costcenter&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            org_assignment = lt_orgassignment&lt;/P&gt;&lt;P&gt;            personal_data  = lt_personal_data&lt;/P&gt;&lt;P&gt;            communication  = lt_communication.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT lt_orgassignment INTO ls_orgassignment.&lt;/P&gt;&lt;P&gt;    clear ls_rate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  fill structure for orgunit read&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    MOVE 'O' TO ls_root_objects-otype.&lt;/P&gt;&lt;P&gt;    MOVE ls_orgassignment-org_unit TO ls_root_objects-objid.&lt;/P&gt;&lt;P&gt;    APPEND ls_root_objects TO lt_root_objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    MOVE: ls_orgassignment-perno TO ls_ressource-perno,&lt;/P&gt;&lt;P&gt;          ls_orgassignment-org_unit TO ls_ressource-org_unit,&lt;/P&gt;&lt;P&gt;          ls_orgassignment-position TO ls_ressource-position.&lt;/P&gt;&lt;P&gt;    APPEND ls_ressource TO lt_ressource.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF ls_orgassignment-to_date = '99991231'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    get amount&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      CALL FUNCTION 'HR_GET_TOTAL_AMOUNT_P0008'&lt;/P&gt;&lt;P&gt;           EXPORTING&lt;/P&gt;&lt;P&gt;                pernr    = ls_orgassignment-perno&lt;/P&gt;&lt;P&gt;           IMPORTING&lt;/P&gt;&lt;P&gt;                amount   = ls_rate-amount_month&lt;/P&gt;&lt;P&gt;                currency = ls_rate-waers&lt;/P&gt;&lt;P&gt;           EXCEPTIONS&lt;/P&gt;&lt;P&gt;                OTHERS   = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      REFRESH p0008.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      CALL FUNCTION 'HR_READ_INFOTYPE'&lt;/P&gt;&lt;P&gt;           EXPORTING&lt;/P&gt;&lt;P&gt;                pernr     = ls_orgassignment-perno&lt;/P&gt;&lt;P&gt;                infty     = '0008'&lt;/P&gt;&lt;P&gt;                begda     = sy-datum&lt;/P&gt;&lt;P&gt;                endda     = sy-datum&lt;/P&gt;&lt;P&gt;           TABLES&lt;/P&gt;&lt;P&gt;                infty_tab = p0008&lt;/P&gt;&lt;P&gt;           EXCEPTIONS&lt;/P&gt;&lt;P&gt;                OTHERS    = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    get amount per hour&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      READ TABLE p0008 INDEX 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      if not p0008-divgv is initial.&lt;/P&gt;&lt;P&gt;        ls_rate-amount_hour = ls_rate-amount_month / p0008-divgv.&lt;/P&gt;&lt;P&gt;      else.&lt;/P&gt;&lt;P&gt;        refresh p0007.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        CALL FUNCTION 'HR_READ_INFOTYPE'&lt;/P&gt;&lt;P&gt;           EXPORTING&lt;/P&gt;&lt;P&gt;                pernr     = ls_orgassignment-perno&lt;/P&gt;&lt;P&gt;                infty     = '0007'&lt;/P&gt;&lt;P&gt;                begda     = sy-datum&lt;/P&gt;&lt;P&gt;                endda     = sy-datum&lt;/P&gt;&lt;P&gt;           TABLES&lt;/P&gt;&lt;P&gt;                infty_tab = p0007&lt;/P&gt;&lt;P&gt;           EXCEPTIONS&lt;/P&gt;&lt;P&gt;                OTHERS    = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        if sy-subrc is initial.&lt;/P&gt;&lt;P&gt;          ls_rate-amount_hour = ls_rate-amount_month / p0007-MOSTD.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    get amount month&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      CALL FUNCTION 'HR_GET_TOTAL_AMOUNT_P0008'&lt;/P&gt;&lt;P&gt;           EXPORTING&lt;/P&gt;&lt;P&gt;                pernr     = ls_orgassignment-perno&lt;/P&gt;&lt;P&gt;                frequency = '01'&lt;/P&gt;&lt;P&gt;           IMPORTING&lt;/P&gt;&lt;P&gt;                amount    = ls_rate-amount_month&lt;/P&gt;&lt;P&gt;                currency  = ls_rate-waers&lt;/P&gt;&lt;P&gt;           EXCEPTIONS&lt;/P&gt;&lt;P&gt;                OTHERS    = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      MOVE: ls_orgassignment-to_date  TO ls_rate-to_date,&lt;/P&gt;&lt;P&gt;            ls_orgassignment-from_date TO ls_rate-from_date,&lt;/P&gt;&lt;P&gt;            ls_orgassignment-perno TO ls_rate-perno.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      APPEND ls_rate TO lt_rate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SORT lt_root_objects BY objid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DELETE ADJACENT DUPLICATES FROM lt_root_objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;fill buffer with org objects&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'STRUCTURE_BUILD_MULTIPLE_ROOTS'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            plvar           = lf_plvar&lt;/P&gt;&lt;P&gt;            wegid           = 'O-O_DOWN'&lt;/P&gt;&lt;P&gt;            sbegd           = sy-datum&lt;/P&gt;&lt;P&gt;            sendd           = sy-datum&lt;/P&gt;&lt;P&gt;            cbflag          = 'X'&lt;/P&gt;&lt;P&gt;            tflag           = 'X'&lt;/P&gt;&lt;P&gt;       IMPORTING&lt;/P&gt;&lt;P&gt;            cb_nr           = lf_contr_block_nr&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            root_objects    = lt_root_objects&lt;/P&gt;&lt;P&gt;            root_tab        = lt_root_tab&lt;/P&gt;&lt;P&gt;       EXCEPTIONS&lt;/P&gt;&lt;P&gt;            root_not_found  = 1&lt;/P&gt;&lt;P&gt;            wegid_not_found = 2&lt;/P&gt;&lt;P&gt;            OTHERS          = 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DESCRIBE TABLE lt_root_tab LINES lf_lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF lf_lines &amp;gt; 1.&lt;/P&gt;&lt;P&gt;    DELETE lt_root_tab INDEX 1.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT lt_root_tab INTO ls_root_tab.&lt;/P&gt;&lt;P&gt;    CLEAR: ls_entry,&lt;/P&gt;&lt;P&gt;           ls_orgunits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  get texts for root objects&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    CALL FUNCTION 'RH_READ_OBJECT'&lt;/P&gt;&lt;P&gt;         EXPORTING&lt;/P&gt;&lt;P&gt;              plvar     = lf_plvar&lt;/P&gt;&lt;P&gt;              otype     = ls_root_tab-otype&lt;/P&gt;&lt;P&gt;              objid     = ls_root_tab-objid&lt;/P&gt;&lt;P&gt;              begda     = ls_root_tab-sbegd&lt;/P&gt;&lt;P&gt;              endda     = ls_root_tab-sendd&lt;/P&gt;&lt;P&gt;         IMPORTING&lt;/P&gt;&lt;P&gt;              short     = ls_orgunits-org_short&lt;/P&gt;&lt;P&gt;              stext     = ls_orgunits-org_long&lt;/P&gt;&lt;P&gt;         EXCEPTIONS&lt;/P&gt;&lt;P&gt;              not_found = 1&lt;/P&gt;&lt;P&gt;              OTHERS    = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ls_orgunits-otype   = ls_root_tab-otype.&lt;/P&gt;&lt;P&gt;    ls_orgunits-orgunit = ls_root_tab-objid.&lt;/P&gt;&lt;P&gt;    ls_orgunits-level   = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  get all subordinate objects&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    WHILE ls_entry-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      CALL FUNCTION 'STRUCTURE_ENTRY_GET'&lt;/P&gt;&lt;P&gt;           EXPORTING&lt;/P&gt;&lt;P&gt;                index  = ls_root_tab-pstru&lt;/P&gt;&lt;P&gt;                cb_nr  = lf_contr_block_nr&lt;/P&gt;&lt;P&gt;           IMPORTING&lt;/P&gt;&lt;P&gt;                object = ls_object&lt;/P&gt;&lt;P&gt;                root   = ls_root&lt;/P&gt;&lt;P&gt;                entry  = ls_entry&lt;/P&gt;&lt;P&gt;           EXCEPTIONS&lt;/P&gt;&lt;P&gt;                OTHERS = 1.&lt;/P&gt;&lt;P&gt;      IF ls_entry-subrc = 0.&lt;/P&gt;&lt;P&gt;        MOVE: ls_root_tab-objid TO ls_orgunits-parent,&lt;/P&gt;&lt;P&gt;              ls_object-otype   TO ls_orgunits-otype,&lt;/P&gt;&lt;P&gt;              ls_object-objid   TO ls_orgunits-orgunit,&lt;/P&gt;&lt;P&gt;              ls_object-short   TO ls_orgunits-org_short,&lt;/P&gt;&lt;P&gt;              ls_object-stext   TO ls_orgunits-org_long,&lt;/P&gt;&lt;P&gt;              ls_entry-level    TO ls_orgunits-level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        APPEND ls_orgunits TO lt_orgunits.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDWHILE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF lt_orgunits IS INITIAL.&lt;/P&gt;&lt;P&gt;    APPEND ls_orgunits TO lt_orgunits.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DELETE ADJACENT DUPLICATES FROM lt_orgunits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Check if any person is leader of orgunit&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT lt_ressource ASSIGNING &amp;lt;ls_ressource&amp;gt;.&lt;/P&gt;&lt;P&gt;    DATA: ls_objects TYPE hrobject,&lt;/P&gt;&lt;P&gt;          lt_objects TYPE TABLE OF hrobject,&lt;/P&gt;&lt;P&gt;          lt_it001 TYPE TABLE OF string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    REFRESH lt_objects.&lt;/P&gt;&lt;P&gt;    MOVE: '01' TO ls_objects-plvar,&lt;/P&gt;&lt;P&gt;          'S' TO ls_objects-otype,&lt;/P&gt;&lt;P&gt;          &amp;lt;ls_ressource&amp;gt;-position TO ls_objects-objid.&lt;/P&gt;&lt;P&gt;    APPEND ls_objects TO lt_objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CALL FUNCTION 'RH_READ_INFTY_1001'&lt;/P&gt;&lt;P&gt;         EXPORTING&lt;/P&gt;&lt;P&gt;              subty           = 'A012'&lt;/P&gt;&lt;P&gt;         TABLES&lt;/P&gt;&lt;P&gt;              i1001           = lt_it001&lt;/P&gt;&lt;P&gt;              objects         = lt_objects&lt;/P&gt;&lt;P&gt;         EXCEPTIONS&lt;/P&gt;&lt;P&gt;              nothing_found   = 1&lt;/P&gt;&lt;P&gt;              wrong_condition = 2&lt;/P&gt;&lt;P&gt;              OTHERS          = 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF sy-subrc IS INITIAL.&lt;/P&gt;&lt;P&gt;      &amp;lt;ls_ressource&amp;gt;-leadpos = 'X'.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      CLEAR &amp;lt;ls_ressource&amp;gt;-leadpos.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;start creating of xml stream&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CLEAR gt_xml.&lt;/P&gt;&lt;P&gt;  gs_xml-line = '&amp;lt;Request&amp;gt;'.&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  gs_xml-line = ' &amp;lt;ProcessHRDataSAP&amp;gt;'.&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  gs_xml-line = '  &amp;lt;HumanResources&amp;gt;'.                       "#EC NOTEXT&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT lt_personal_data INTO ls_personal_data.&lt;/P&gt;&lt;P&gt;    PERFORM insert_personal_data USING lt_communication&lt;/P&gt;&lt;P&gt;                                       lt_rate&lt;/P&gt;&lt;P&gt;                                 CHANGING ls_personal_data&lt;/P&gt;&lt;P&gt;                                          gt_xml.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;  gs_xml-line = '  &amp;lt;/HumanResources&amp;gt;'.                      "#EC NOTEXT&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  gs_xml-line = '  &amp;lt;OrganisationStructure&amp;gt;'.                "#EC NOTEXT&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;  LOOP AT lt_orgunits INTO ls_orgunits.&lt;/P&gt;&lt;P&gt;    PERFORM insert_orgassignment_data USING ls_orgunits&lt;/P&gt;&lt;P&gt;                                   CHANGING gt_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;  DESCRIBE TABLE lt_orgunits LINES lf_lines.&lt;/P&gt;&lt;P&gt;  IF lf_lines &amp;gt; 1.&lt;/P&gt;&lt;P&gt;    CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;    gs_xml-line = '   &amp;lt;/OrganisationUnit&amp;gt;'.                 "#EC NOTEXT&lt;/P&gt;&lt;P&gt;    APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;  gs_xml-line = '  &amp;lt;/OrganisationStructure&amp;gt;'.               "#EC NOTEXT&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Resource Mapping&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;  gs_xml-line = '  &amp;lt;ResourceMapping&amp;gt;'.                      "#EC NOTEXT&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT lt_ressource INTO ls_ressource.&lt;/P&gt;&lt;P&gt;    PERFORM insert_ressource_data USING ls_ressource&lt;/P&gt;&lt;P&gt;                                  CHANGING gt_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;  gs_xml-line = '  &amp;lt;/ResourceMapping&amp;gt;'.                     "#EC NOTEXT&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;  gs_xml-line = ' &amp;lt;/ProcessHRDataSAP&amp;gt;'.                     "#EC NOTEXT&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The last tag must be the root closing tag --*&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  gs_xml-line = '&amp;lt;/Request&amp;gt;'.&lt;/P&gt;&lt;P&gt;  APPEND gs_xml TO gt_xml.&lt;/P&gt;&lt;P&gt;  CLEAR gs_xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;In case no file path is provided&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  IF i_filename IS INITIAL.&lt;/P&gt;&lt;P&gt;    i_filename = 'C:\XML\EMPLOYEE.XML'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Drop the XML-FILE in Temp file folder&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL METHOD cl_gui_frontend_services=&amp;gt;gui_download&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      filename                = 'C:\TEMP\EMPLOYEE.XML'&lt;/P&gt;&lt;P&gt;      filetype                = 'ASC'&lt;/P&gt;&lt;P&gt;    CHANGING&lt;/P&gt;&lt;P&gt;      data_tab                = gt_xml&lt;/P&gt;&lt;P&gt;      EXCEPTIONS&lt;/P&gt;&lt;P&gt;        file_write_error        = 1&lt;/P&gt;&lt;P&gt;        no_batch                = 2&lt;/P&gt;&lt;P&gt;        gui_refuse_filetransfer = 3&lt;/P&gt;&lt;P&gt;        invalid_type            = 4&lt;/P&gt;&lt;P&gt;        no_authority            = 5&lt;/P&gt;&lt;P&gt;        unknown_error           = 6&lt;/P&gt;&lt;P&gt;        header_not_allowed      = 7&lt;/P&gt;&lt;P&gt;        separator_not_allowed   = 8&lt;/P&gt;&lt;P&gt;        filesize_not_allowed    = 9&lt;/P&gt;&lt;P&gt;        header_too_long         = 10&lt;/P&gt;&lt;P&gt;        dp_error_create         = 11&lt;/P&gt;&lt;P&gt;        dp_error_send           = 12&lt;/P&gt;&lt;P&gt;        dp_error_write          = 13&lt;/P&gt;&lt;P&gt;        unknown_dp_error        = 14&lt;/P&gt;&lt;P&gt;        access_denied           = 15&lt;/P&gt;&lt;P&gt;        dp_out_of_memory        = 16&lt;/P&gt;&lt;P&gt;        disk_full               = 17&lt;/P&gt;&lt;P&gt;        dp_timeout              = 18&lt;/P&gt;&lt;P&gt;        file_not_found          = 19&lt;/P&gt;&lt;P&gt;        dataprovider_exception  = 20&lt;/P&gt;&lt;P&gt;        control_flush_error     = 21&lt;/P&gt;&lt;P&gt;        OTHERS                  = 24.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;copy the XML-file from temp file folder to the filename&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL METHOD cl_gui_frontend_services=&amp;gt;file_copy&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      source             = 'C:\TEMP\EMPLOYEE.XML'&lt;/P&gt;&lt;P&gt;      destination        = i_filename&lt;/P&gt;&lt;P&gt;      overwrite          = 'X'&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      cntl_error         = 1&lt;/P&gt;&lt;P&gt;      error_no_gui       = 2&lt;/P&gt;&lt;P&gt;      wrong_parameter    = 3&lt;/P&gt;&lt;P&gt;      disk_full          = 4&lt;/P&gt;&lt;P&gt;      access_denied      = 5&lt;/P&gt;&lt;P&gt;      file_not_found     = 6&lt;/P&gt;&lt;P&gt;      destination_exists = 7&lt;/P&gt;&lt;P&gt;      unknown_error      = 8&lt;/P&gt;&lt;P&gt;      path_not_found     = 9&lt;/P&gt;&lt;P&gt;      disk_write_protect = 10&lt;/P&gt;&lt;P&gt;      drive_not_ready    = 11&lt;/P&gt;&lt;P&gt;      OTHERS             = 12&lt;/P&gt;&lt;P&gt;          .&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;delete the temp file&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL METHOD cl_gui_frontend_services=&amp;gt;file_delete&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      filename           = 'C:\TEMP\EMPLOYEE.XML'&lt;/P&gt;&lt;P&gt;    CHANGING&lt;/P&gt;&lt;P&gt;      rc                 = lf_return_code&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      file_delete_failed = 1&lt;/P&gt;&lt;P&gt;      cntl_error         = 2&lt;/P&gt;&lt;P&gt;      error_no_gui       = 3&lt;/P&gt;&lt;P&gt;      file_not_found     = 4&lt;/P&gt;&lt;P&gt;      access_denied      = 5&lt;/P&gt;&lt;P&gt;      unknown_error      = 6&lt;/P&gt;&lt;P&gt;      OTHERS             = 7 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFUNCTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Import Parameters for the above function module:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) I_COSTCENTER    like BAPIEMPLB-COSTCENTER      default  &amp;#145;*&amp;#146;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) I_FILENAME  TYPE STRING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone explain the reason for that error and give the necessary corrections in the code.  When I give some dummy value for the costcenter  field, the xml file is created without any data in it. Can you correct this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Srinivas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Nov 2006 10:09:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/type-casting-error-in-a-function-module/m-p/1710800#M310925</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-02T10:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Type casting error in a Function Module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/type-casting-error-in-a-function-module/m-p/1710801#M310926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;U have used datatypes like typ_s_ressource...&lt;/P&gt;&lt;P&gt;r they defined in TOP include? What is the exact declaration of the same?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Nov 2006 10:44:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/type-casting-error-in-a-function-module/m-p/1710801#M310926</guid>
      <dc:creator>kanthimathikris</dc:creator>
      <dc:date>2006-11-02T10:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Type casting error in a Function Module</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/type-casting-error-in-a-function-module/m-p/1710802#M310927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the data types like typ_s_ressource are defined.&lt;/P&gt;&lt;P&gt;they are declared in the include LZTPGTOP.&lt;/P&gt;&lt;P&gt;The declaration of typ_s_ressource is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of typ_s_ressource,&lt;/P&gt;&lt;P&gt;        perno type hrsobid-sobid,&lt;/P&gt;&lt;P&gt;        org_unit type objid,&lt;/P&gt;&lt;P&gt;        position type hrsobid-sobid,&lt;/P&gt;&lt;P&gt;        leadpos type c,&lt;/P&gt;&lt;P&gt;       end of typ_s_ressource.&lt;/P&gt;&lt;P&gt;If u have any questions, you can ask me, but try to provide a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Srinivas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Nov 2006 12:02:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/type-casting-error-in-a-function-module/m-p/1710802#M310927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-02T12:02:46Z</dc:date>
    </item>
  </channel>
</rss>

