Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8604

Re: How to convert one data type to another data type ?

$
0
0

hikiran,

 

REPORT z_upload.

SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS     : aps_ztab RADIOBUTTON GROUP abc.

PARAMETERS     : prs_ztab RADIOBUTTON GROUP abc  MODIF ID fda.

SELECTION-SCREEN:END OF BLOCK b1.

 

TABLES:zdsl.

field-symbols: <fl_dat> type any.

TYPES: BEGIN OF ty_zdsl,

  mandtTYPE zdsl-mandt,

        werksTYPE zdsl-werks,

        pallet_id TYPE zdsl-pallet_id,

        matnrTYPE zdsl-matnr,

        erfmg(20) TYPE c,

        uomTYPE zdsl-uom,

        lgortTYPE zdsl-lgort,

        lotTYPE zdsl-lot,

        prod_date TYPE zdsl-prod_date,

        ebelnTYPE zdsl-ebeln,

        erdatTYPE zdsl-erdat,

        erzetTYPE zdsl-erdat,

        ernamTYPE zdsl-ernam,

        aedatTYPE zdsl-aedat,

        usernameTYPE zdsl-username,

        flocTYPE zdsl-floc,

   END OF ty_zdsl.

 

data:it_zdsl type table of ty_zdsl with header line,

         wa_zdsl type ty_zdsl.

data: me_zdsl type table of zdslwith header line,

       wa2 type zdsl.

 

DATA:p_file TYPE rlgrap-filename,

      s_file TYPE rlgrap-filename,

      t_file TYPE string.

 

IF aps_ztab  = 'X'.

   PERFORM apserv_itab.

   PERFORM itable_ztab.

ENDIF.

 

IF prs_ztab = 'X'.

   PERFORM pserver_itab.      " file uploaded from presentation server to internal table"

   PERFORM itable_ztab.       " updating standard table  by using internal table"

ENDIF.

 

 

 

 

*&---------------------------------------------------------------------*

*&      Form  PSERVER_ITAB

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM pserver_itab .

 

   s_file = 'C:\Users\Owner\Documents\suneel.txt'.

   t_file = s_file.

   CALL FUNCTION 'GUI_UPLOAD'

     EXPORTING

       filename                      = t_file

      filetype                      = 'ASC'

      has_field_separator           = 'X'

*     HEADER_LENGTH                 = 0

*     READ_BY_LINE                  = 'X'

*     DAT_MODE                      = ' '

*     CODEPAGE                      = ' '

*     IGNORE_CERR                   = ABAP_TRUE

*     REPLACEMENT                   = '#'

*     CHECK_BOM                     = ' '

*     VIRUS_SCAN_PROFILE            =

*     NO_AUTH_CHECK                 = ' '

*     ISDOWNLOAD                    = ' '

*   IMPORTING

*     FILELENGTH                    =

*     HEADER                        =

     TABLES

       data_tab                      = it_zdsl

*   CHANGING

*     ISSCANPERFORMED               = ' '

    EXCEPTIONS

      file_open_error               = 1

      file_read_error               = 2

      no_batch                      = 3

      gui_refuse_filetransfer       = 4

      invalid_type                  = 5

      no_authority                  = 6

      unknown_error                 = 7

      bad_data_format               = 8

      header_not_allowed            = 9

      separator_not_allowed         = 10

      header_too_long               = 11

      unknown_dp_error              = 12

      access_denied                 = 13

      dp_out_of_memory              = 14

      disk_full                     = 15

      dp_timeout                    = 16

      OTHERS                        = 17

             .

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

 

ENDFORM.                    " PSERVER_ITAB

*&---------------------------------------------------------------------*

*&      Form  APSERV_ITAB

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM apserv_itab .

   DATA:l_data TYPE string.

   p_file = '\\dj56bi00v\migration\migration\CSVManual\suneel.txt'.

   OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

   IF sy-subrc NE 0.

     MESSAGE 'UNABLE TO OPEN THE FILE' TYPE 'I'.

   ENDIF.

   DO.

     READ DATASET p_file INTO l_data.

     IF sy-subrc = 0.

       SPLIT l_data AT cl_abap_char_utilities=>horizontal_tab  INTO wa_zdsl-mandt

                               wa_zdsl-werks

                               wa_zdsl-pallet_id

                               wa_zdsl-matnr

                               wa_zdsl-erfmg

                               wa_zdsl-uom

                               wa_zdsl-lgort

                               wa_zdsl-lot

                               wa_zdsl-prod_date

                               wa_zdsl-ebeln

                               wa_zdsl-erdat

                               wa_zdsl-erzet

                               wa_zdsl-ernam

                               wa_zdsl-aedat

                               wa_zdsl-username

                               wa_zdsl-floc.

move-corresponding it_zdsl to me_zdsl.

ASSIGN it_zdsl-erfmg to <Fl_D>.

me_zdsl-erfmg = <Fl_DAT>.

append me_zdsl.

     ELSE.

       EXIT.

     ENDIF.

   ENDDO.

 

 

ENDFORM.                    " APSERV_ITAB

*&---------------------------------------------------------------------*

*&      Form  ITABLE_ZTAB

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM itable_ztab .

          inser zdsl from table me_zdsl.

          commit work and wait.

   LOOP AT me_zdsl INTO wa_zdsl.

     WRITE:/1 wa_zdsl-mandt,

             10 wa_zdsl-werks,

             30 wa_zdsl-pallet_id,

             45  wa_zdsl-matnr,

             60 wa_zdsl-erfmg,

             75 wa_zdsl-uom,

             90 wa_zdsl-lgort,

             105 wa_zdsl-lot,

             125 wa_zdsl-prod_date,

             140 wa_zdsl-ebeln,

             155 wa_zdsl-erdat,

             170 wa_zdsl-erzet,

             185 wa_zdsl-ernam,

             190  wa_zdsl-aedat,

             210 wa_zdsl-username,

             230 wa_zdsl-floc.

     CLEAR wa_zdsl.

      

   ENDLOOP.

 

 

ENDFORM. 


Viewing all articles
Browse latest Browse all 8604

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>