<?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 Sample code of SCMS_XSTRING_TO_BINARY and SCMS_BINARY_TO_STRING. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-of-scms-xstring-to-binary-and-scms-binary-to-string/m-p/4167930#M996422</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could any guru give sample code for the following function module:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SCMS_XSTRING_TO_BINARY&lt;/P&gt;&lt;P&gt;SCMS_BINARY_TO_STRING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Jul 2008 10:13:29 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-18T10:13:29Z</dc:date>
    <item>
      <title>Sample code of SCMS_XSTRING_TO_BINARY and SCMS_BINARY_TO_STRING.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-of-scms-xstring-to-binary-and-scms-binary-to-string/m-p/4167930#M996422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could any guru give sample code for the following function module:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SCMS_XSTRING_TO_BINARY&lt;/P&gt;&lt;P&gt;SCMS_BINARY_TO_STRING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2008 10:13:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-of-scms-xstring-to-binary-and-scms-binary-to-string/m-p/4167930#M996422</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-18T10:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sample code of SCMS_XSTRING_TO_BINARY and SCMS_BINARY_TO_STRING.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-of-scms-xstring-to-binary-and-scms-binary-to-string/m-p/4167931#M996423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Check this links:&lt;/P&gt;&lt;P&gt;SCMS_XSTRING_TO_BINARY:&lt;/P&gt;&lt;P&gt;&lt;A href="http://blog.csdn.net/CompassButton/archive/2007/08/08/1731473.aspx" target="test_blank"&gt;http://blog.csdn.net/CompassButton/archive/2007/08/08/1731473.aspx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SCMS_BINARY_TO_STRING:&lt;/P&gt;&lt;P&gt;&lt;A href="http://code.google.com/p/saplink/issues/detail?id=106" target="test_blank"&gt;http://code.google.com/p/saplink/issues/detail?id=106&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Search SDN form with function module name's.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Adil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2008 10:19:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-of-scms-xstring-to-binary-and-scms-binary-to-string/m-p/4167931#M996423</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-18T10:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Sample code of SCMS_XSTRING_TO_BINARY and SCMS_BINARY_TO_STRING.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-of-scms-xstring-to-binary-and-scms-binary-to-string/m-p/4167932#M996424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the Program..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  ZSAMPLE_CODE.

************************************************************************
*                   Declaration of Global Data Variables               *
************************************************************************
DATA : org_xml TYPE xstring,
       i_mess  TYPE bapiret1.

************************************************************************
*                      Formatting Selection Screen                     *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-110.
PARAMETERS : p_viewid TYPE  twpc_v-viewid ,
             p_otype  TYPE  otype DEFAULT 'O' NO-DISPLAY,
             p_objid  TYPE  p0001-orgeh ,
             p_date   TYPE  sy-datum DEFAULT sy-datum.
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-111.
SELECTION-SCREEN: BEGIN OF LINE.
*-- Unix File
SELECTION-SCREEN: COMMENT 1(30)  text-100 .
SELECTION-SCREEN: POSITION 33.
*-- Unix File Radio Button
PARAMETERS: p_show AS CHECKBOX.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-105.
SELECTION-SCREEN: BEGIN OF LINE.
*-- Unix File
SELECTION-SCREEN: COMMENT 1(10) text-107.
SELECTION-SCREEN: POSITION 12.
*-- Unix File Radio Button
PARAMETERS: p_unix RADIOBUTTON GROUP r1.
SELECTION-SCREEN: POSITION 15.
*-- Unix File Name
PARAMETERS: p_ufile LIKE rlgrap-filename LOWER CASE.
SELECTION-SCREEN: END OF LINE.

SELECTION-SCREEN: BEGIN OF LINE.
*-- PC File
SELECTION-SCREEN: COMMENT 1(10) text-108.
SELECTION-SCREEN: POSITION 12.
*-- PC File Radio Button
PARAMETERS: p_pc RADIOBUTTON GROUP r1.
SELECTION-SCREEN: POSITION 15.
*-- PC File Name
PARAMETERS: p_pcfile LIKE rlgrap-filename.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN END OF BLOCK b4.


************************************************************************
*    Validation &amp;amp; Value Request Functionality on Selection Screen      *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pcfile.
*-- Value Request Functionality for PC File
  PERFORM value_request_for_pc_file USING p_pcfile.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_objid.
  CALL FUNCTION 'RP_PNP_GET_VALUE_ORGEH'
    CHANGING
      orgeh = p_objid.


************************************************************************
*                      Start of Selection                              *
************************************************************************
START-OF-SELECTION.

  PERFORM set_values.
  PERFORM get_xml_file.
  PERFORM download_file.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  value_request_for_pc_file
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM value_request_for_pc_file USING p_filepath.

  CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      file_name = p_filepath.


ENDFORM.                    " value_request_for_pc_file
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  get_xml_file
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM get_xml_file .

  DATA : l_objid TYPE realo.

  MOVE p_objid TO l_objid.

  CALL FUNCTION 'HCM_GET_ORGSTRUCTURE_AS_XML_IN'
    EXPORTING
      i_viewid    = p_viewid
      i_otype     = p_otype
      i_objid     = l_objid
      i_begindate = p_date
      i_enddate   = p_date
      i_keydate   = p_date
      i_debugmode = p_show
    IMPORTING
      xmlstring   = org_xml
      return      = i_mess.


  IF i_mess IS NOT INITIAL AND i_mess-type = 'E'.
    WRITE : / 'OrgPlus Extraction Failed. Reason :', i_mess-message.
    STOP.
  ENDIF.


ENDFORM.                    " get_xml_file
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  download_file
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM download_file .

  IF org_xml IS INITIAL.
    WRITE :/ 'No File to Download.'.
    STOP.
  ENDIF.

  IF p_pc = 'X' AND p_pcfile IS NOT INITIAL.
    PERFORM download_to_pc.
  ELSEIF p_unix = 'X' AND p_ufile IS NOT INITIAL.
    PERFORM download_to_unix.
  ENDIF.

ENDFORM.                    " download_file
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  download_to_pc
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM download_to_pc .

  DATA: filesize TYPE i,
        filename TYPE string.

  DATA : BEGIN OF itab OCCURS 0,
           line TYPE x LENGTH 255,
         END OF itab.

  MOVE p_pcfile TO filename.

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer        = org_xml
    IMPORTING
      output_length = filesize
    TABLES
      binary_tab    = itab.


* download into file
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      bin_filesize = filesize
      filename     = filename
      filetype     = 'BIN'
    TABLES
      data_tab     = itab
    EXCEPTIONS
      OTHERS       = 1.

  IF sy-subrc NE 0.
    WRITE : / 'Error downloading File to PC Path : ', filename.
    STOP.
  ELSE.
    WRITE : / 'File downloaded to PC Path : ', filename.
  ENDIF.

ENDFORM.                    " download_to_pc
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  download_to_unix
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM download_to_unix .

  OPEN DATASET p_ufile FOR OUTPUT IN BINARY MODE.
  IF sy-subrc NE 0.
    WRITE : / 'Error Opening the Server Filepath :', p_ufile.
    STOP.
  ELSE.
    WRITE : / 'File Downloaded to the Server at :', p_ufile.
  ENDIF.

  TRANSFER org_xml TO p_ufile.
  CLOSE DATASET p_ufile.


ENDFORM.                    " download_to_unix
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  set_values
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM set_values .

  IF sy-batch = 'X'.
    CLEAR p_show .
  ENDIF.

ENDFORM.                    " set_values&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2008 10:23:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-of-scms-xstring-to-binary-and-scms-binary-to-string/m-p/4167932#M996424</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-18T10:23:12Z</dc:date>
    </item>
  </channel>
</rss>

