4 Replies Latest reply: Apr 2, 2012 11:25 AM by Deepan Ignaatious RSS

Conversion problem when spiting files from application server?

Deepan Ignaatious
Currently Being Moderated

I have a file in application server since when i read file from application server it will be encoded with # instead of tabspace.so i have to split it at # or con_tab.

but what if the one of the field in file is of type I.its showing it can be only of type c or string.

 

Here is it WA_ITEM-KWMENG. field

wa1 is of type string.

file1 is of string.

how can i split that field .how to proceed what to do??

 

 

*OPEN DATASET ITEM1 FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

*DO.

*    IF SY-SUBRC <> 0.

*      EXIT.

*    ENDIF.

*    READ DATASET ITEM1 INTO WA1.

*    IF sy-subrc = 0.

*      SPLIT wa1 AT con_tab  INTO WA_ITEM-key

*                                 WA_ITEM-KUNNR

*                                 WA_ITEM-KUNNR2

*                                 WA_ITEM-BNDDT

*                                 WA_ITEM-MATNR

*                                 WA_ITEM-KWMENG.

*

*

*    APPEND WA_ITEM to it_ITEM.

*    ENDIF.

*

*ENDDO.

*CLOSE DATASET ITEM1.

  • Re: Conversion problem when spiting files from application server?
    Manu D'Haeyer
    Currently Being Moderated

    Hi,

    Well, use another char field to take care of that:

          SPLIT wa1 AT con_tab  INTO WA_ITEM-key

                                     WA_ITEM-KUNNR

                                     WA_ITEM-KUNNR2

                                     WA_ITEM-BNDDT

                                     WA_ITEM-MATNR

                                     L_KWMENG_C.   "char/string field

         IF L_KWMENG_C IS NOT INITIAL.

              WA_ITEM-KWMENG = L_KWMENG_C.

        ENDIF.

    ...

     

    Kr,

    Manu.

  • Re: Conversion problem when spiting files from application server?
    Bala Krishna
    Currently Being Moderated

    Hi,

        Use SPLIT statement with INTO TABLE addition. Just check out below example, modify as per your structure declarations.

    TYPES : BEGIN OF ty_text,

                  text(40) TYPE c,

             END OF ty_text.

     

    TYPES : BEGIN OF ty_item,

               key    TYPE n LENGTH 5,

               kunnr  TYPE kna1-kunnr,

               kunnr2 TYPE kna1-kunnr,

               bnddt  TYPE sy-datum,

               matnr  TYPE vbap-matnr,

               kwmeng TYPE vbap-kwmeng,

             END OF ty_item.

     

    DATA : i_item  TYPE STANDARD TABLE OF ty_item,

            i_word  TYPE TABLE OF ty_text,

            wa_word TYPE ty_text,

            item1   TYPE rlgrap-filename,

            wa1     TYPE string.

      FIELD-SYMBOLS : <fs_line>  TYPE ty_item,

                     <fs_field> TYPE any.

     

      OPEN DATASET item1 FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

      DO .

        READ DATASET item1 INTO wa1.

        IF sy-subrc <> 0.

          EXIT.

       ELSE.

          SPLIT wa1 AT '#' INTO TABLE i_word.

          LOOP AT i_word INTO wa_word.

            ASSIGN COMPONENT sy-tabix OF STRUCTURE <fs_line> TO <fs_field>.

            IF sy-subrc <> 0.

              EXIT.

            ENDIF.

            <fs_field> = wa_word-text.

            CLEAR : wa_word.

          ENDLOOP.

          INSERT <fs_line> INTO TABLE i_item.

          CLEAR : <fs_line>, <fs_field>.

        ENDIF.

      ENDDO.

      CLOSE DATASET item1.

     

    Thanks & Regards

    Bala Krishna

  • Conversion problem when spiting files from application server?
    Deepan Ignaatious
    Currently Being Moderated

    Thanks all...Issue solved..:)

Actions