Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Internal Tables

Former Member
0 Likes
960

I have a samll Question :

I have in entry of Method an internal table , and I ignore the fields contain on it.

the goal is to separate each two fields with separator. and write it in text file.

how I can do that :

Ex:

Internal table

PP OO KK

MM CC TT

What I want to do is :

PP;OO;KK

MM;CC;TT

Note That I ignore the structure of the table. I know just that is table

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
935

HI,

You know the lenth of the field in the internal table,

so write like

Loop at itab.

Move itab-File+0(2) to copyfield.

Move Copyfield to text.

move itab-field+2(2) to copyfield.

concatinate copyfield text into text separeted by ':'.

move itab-field+4(2) to copyfield.

concatinate copyfield text into text separeted by ':'

endloop.

So at the last you wil have the exact value in the TEXT field

Regards

Sudheer

10 REPLIES 10
Read only

Former Member
0 Likes
935

Hi

U can use fm SAP_CONVERT_TO_CSV_FORMAT

Max

Read only

0 Likes
935

Hi every one,

I have a question about ABAP Object...

Can a class have an attribute as Table (satndard)...??

Otherwise how to avoid it ?

Sincerly

Thanks

Read only

Former Member
0 Likes
936

HI,

You know the lenth of the field in the internal table,

so write like

Loop at itab.

Move itab-File+0(2) to copyfield.

Move Copyfield to text.

move itab-field+2(2) to copyfield.

concatinate copyfield text into text separeted by ':'.

move itab-field+4(2) to copyfield.

concatinate copyfield text into text separeted by ':'

endloop.

So at the last you wil have the exact value in the TEXT field

Regards

Sudheer

Read only

0 Likes
935

My internal Table is Standard table without header line ...

What's copyfiled....and Itab-File.

Itab-File are not accepted by the compilator..

Thanks

Read only

0 Likes
935

Hi

Can't you use fm SAP_CONVERT_TO_CSV_FORMAT?

I you need to do by yourself, perhaps this can be helful for you.

It's a method I developed to insert an element as separator:

- Definition

METHODS:  INSERT_SEPARATOR_CHAR
                   IMPORTING
                     SEPARATOR TYPE STRING
                     RECORD_IN TYPE ANY
                     NO_GAPS   TYPE C DEFAULT SPACE
                   EXPORTING
                     RECORD_OUT  TYPE STRING.

- Implemetation

 METHOD INSERT_SEPARATOR_CHAR.

    FIELD-SYMBOLS: <FS_FIELD> TYPE ANY.

    DATA: WA_STRING(10000) TYPE C.

    DATA: LEN_SEPAR  TYPE I,
          LEN_FIELD  TYPE I,
          LEN_STRING TYPE I.

    LEN_SEPAR = STRLEN( SEPARATOR ).

    DO.
      ASSIGN COMPONENT SY-INDEX OF STRUCTURE RECORD_IN TO <FS_FIELD>.
      IF SY-SUBRC <> 0. EXIT. ENDIF.

      DESCRIBE FIELD <FS_FIELD> LENGTH LEN_FIELD.

      WRITE: <FS_FIELD> TO WA_STRING+LEN_STRING(LEN_FIELD).
      LEN_STRING = LEN_STRING + LEN_FIELD.
      WRITE: SEPARATOR(LEN_SEPAR) TO WA_STRING+LEN_STRING.
      IF NOT NO_GAPS IS INITIAL.
        CONDENSE WA_STRING NO-GAPS.
        LEN_STRING = STRLEN( WA_STRING ).
      ELSE.
        LEN_STRING = LEN_STRING + LEN_SEPAR.
      ENDIF.
    ENDDO.

    LEN_STRING = STRLEN( WA_STRING ).
    MOVE WA_STRING(LEN_STRING) TO RECORD_OUT.

  ENDMETHOD.                    "INSERT_SEPARATOR_CHAR

Max

Read only

0 Likes
935

I can't execute SAP_CONVERT_TO_CSV_FORMAT I don't have it.

For your code i think it's good code but i have a problem with it ....

i have always sy-subrc = 4 after my assign sy-index OF STRUCTURE record_in TO <fs_field>

Note My structure is local structure created in an other program who call the method .....!!

Read only

0 Likes
935

I think that problem is that for me RECORD_IN is internal table and I saw that in the method it's defined like structure.

Read only

0 Likes
935

Hi sorry but finally I found that I can run SAP_CONVERT_TO_CSV_FORMAT.

You know I 'm Really begineer ... in SAP environement.

I have just question related to that SAP_CONVERT_TO_CSV_FORMAT...

The file is only writing on the application server ...How I can do to dispaly the containt of it ...

thanks a lot.

Read only

0 Likes
935

Use Tcode AL11 & look up under the relevant directory to view your file..

~Suresh

Read only

Former Member
0 Likes
935

USE FM GUI_DOWNLOAD

and WRITE_FIELD_SEPARATOR = 'X'.

tab dilimiter

santhosh