Skip to Content
author's profile photo Former Member
Former Member

BDC-Long-Text

Hi All,

When Uploading the Data for FB02, i am facing problem with long-text.I have used FM SAVE_TEXT.But How to Save all the lines Data.Please send me the code for FB02,where all lines data has to be saved.

Thanks&Regards.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Aug 04, 2008 at 10:51 AM

    Sri,

    check this code for more than 5K char:

    TABLES : MARA, TLINE, THEAD.
    
    
    
    DATA: BEGIN OF ITAB OCCURS 0,
    MATNR LIKE MARA-MATNR, " MATERIAL NUMBER
    TEXT(5000) TYPE C, " Long Text
    END OF ITAB.
    
    
    
    DATA: BEGIN OF ITAB1 OCCURS 0,
    MATNR LIKE MARA-MATNR, " Material No
    SEQU TYPE I, " Text Sequence
    TEXT(5000) TYPE C, " Long Text
    END OF ITAB1.
    
    
    
    DATA:BEGIN OF DT_LINES OCCURS 0.
    INCLUDE STRUCTURE TLINE. " Long Text
    DATA:END OF DT_LINES.
    
    
    
    DATA : P_FILE1 TYPE STRING.
    
    
    DATA : DL_NAME TYPE THEAD-TDNAME, " Object Name(material no)
    DL_LAN TYPE THEAD-TDSPRAS. " Language
    
    
    
    
    CONSTANTS:C_BEST TYPE THEAD-TDID VALUE 'BEST',
    C_MATERIAL TYPE THEAD-TDOBJECT VALUE 'MATERIAL'. " OBJECT
    
    
    
    
    DATA: START TYPE I,
    LEN TYPE I VALUE 92,
    TOTLEN TYPE I,
    N TYPE I.
    
    
    
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-101.
    PARAMETERS P_FILE LIKE RLGRAP-FILENAME."input file
    SELECTION-SCREEN : END OF BLOCK B1.
    
    
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    
    PERFORM FETCH_FILE USING P_FILE.
    
    
    
    &---------------------------------------------------------------------
    *& Form fetch_file
    &---------------------------------------------------------------------
    
    
    text 
    ----------------------------------------------------------------------
    
    -->P_FILE text 
    ----------------------------------------------------------------------
    FORM FETCH_FILE USING P_FILE.
    
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    PROGRAM_NAME = SYST-CPROG
    DYNPRO_NUMBER = SYST-DYNNR
    IMPORTING
    FILE_NAME = P_FILE.
    
    ENDFORM. "fetch_file
    
    
    
    START-OF-SELECTION.
    
    PERFORM UPLOAD USING P_FILE. " *To Upload Flat file
    PERFORM UPLOAD_TEXT.
    
    
    
    &---------------------------------------------------------------------
    *& Form UPLOAD
    &---------------------------------------------------------------------
    
    
    text 
    ----------------------------------------------------------------------
    
    -->P_FILE text 
    ----------------------------------------------------------------------
    FORM UPLOAD USING P_FILE.
    
    
    P_FILE1 = P_FILE.
    
    
    
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    FILENAME = P_FILE1
    FILETYPE = 'DAT'
    
    
    HAS_FIELD_SEPARATOR = ' ' 
    HEADER_LENGTH = 0 
    READ_BY_LINE = 'X' 
    DAT_MODE = ' ' 
    CODEPAGE = ' ' 
    IGNORE_CERR = ABAP_TRUE 
    REPLACEMENT = '#' 
    CHECK_BOM = ' ' 
    VIRUS_SCAN_PROFILE = 
    NO_AUTH_CHECK = ' ' 
    IMPORTING 
    FILELENGTH = 
    HEADER = 
    TABLES
    DATA_TAB = ITAB
    
    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 EQ 0.
    
    *message i001 with p_file .
    
    
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO 
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 
    ENDIF.
    
    ENDFORM. "UPLOAD
    
    
    &---------------------------------------------------------------------
    *& Form UPLOAD_TEXT
    &---------------------------------------------------------------------
    
    
    text 
    ----------------------------------------------------------------------
    FORM UPLOAD_TEXT.
    
    LOOP AT ITAB.
    ITAB1-MATNR = ITAB-MATNR.
    
    CLEAR: TOTLEN,N, START.
    
    TOTLEN = STRLEN( ITAB-TEXT ).
    N = TOTLEN / LEN.
    N = N + 1.
    
    DO N TIMES.
    ITAB1-TEXT = ITAB-TEXT+START(LEN).
    ITAB1-SEQU = SY-INDEX.
    START = START + LEN.
    APPEND ITAB1.
    ENDDO.
    ENDLOOP.
    
    
    DELETE ITAB1 WHERE TEXT IS INITIAL.
    SORT ITAB1 BY MATNR SEQU.
    
    LOOP AT ITAB1.
    DT_LINES-TDFORMAT = '*'.
    DT_LINES-TDLINE = ITAB1-TEXT.
    APPEND DT_LINES.
    
    
    AT END OF MATNR.
    DL_LAN = SY-LANGU.
    
    
    WRITE : / itab-MATNR. 
    
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    INPUT = ITAB1-MATNR
    IMPORTING
    OUTPUT = ITAB1-MATNR.
    
    
    
    MOVE ITAB1-MATNR TO DL_NAME.
    
    
    
    CALL FUNCTION 'CREATE_TEXT'
    EXPORTING
    FID = C_BEST
    FLANGUAGE = DL_LAN
    FNAME = DL_NAME
    FOBJECT = C_MATERIAL
    SAVE_DIRECT = 'X'
    FFORMAT = '*'
    TABLES
    FLINES = DT_LINES
    EXCEPTIONS
    NO_INIT = 1
    NO_SAVE = 2
    OTHERS = 3.
    
    IF SY-SUBRC 0.
    
    WRITE:/10 'Long Text Creation failed for Material No', ITAB1-MATNR.
    ELSE.
    
    WRITE:/10 'Long Text Created Successfully for Material No', ITAB1-MATNR.
    
    ENDIF.
    
    
    REFRESH DT_LINES.
    
    ENDAT.
    
    ENDLOOP.
    
    ENDFORM. "UPLOAD_TEXT

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.