Skip to Content
0
Former Member
Aug 04, 2006 at 12:15 PM

problem

21 Views

Hi experts,

See the follwoing code for uploading the text from a text file to Product category header level.

&----


*& Report ZSERENA_INTEGRATION *

*& *

&----


*& *

*& *

&----


REPORT ZSERENA_INTEGRATION .

TABLES: COMM_PCAT_CTV,COMM_PCAT_CTY,THEAD.

DATA: BEGIN OF IT_SERENA OCCURS 0,

ID(19),

TEXT(100),

END OF IT_SERENA.

DATA: FILE_STR TYPE STRING.

DATA: BASIC_TEXT LIKE THEAD OCCURS 0 WITH HEADER LINE.

DATA: YGUID LIKE COMM_PCAT_CTY-GUID,

ZGUID LIKE COMM_PCAT_CTV-PARENT_CATEGORY.

DATA: BASICTEXT like TLINE OCCURS 0 WITH HEADER LINE.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = p_file

STATIC = 'X'

  • MASK = ' '

CHANGING

FILE_NAME = p_file

  • EXCEPTIONS

  • MASK_TOO_LONG = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

START-OF-SELECTION.

FILE_STR = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILE_STR

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = IT_SERENA

  • 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.

  • READ TABLE IT_SERENA INDEX 1.

LOOP AT IT_SERENA.

  • IF sy-subrc = 0.

SELECT SINGLE GUID FROM COMM_PCAT_CTY INTO YGUID

WHERE ID = IT_SERENA-ID.

IF NOT YGUID IS initial.

SELECT SINGLE GUID FROM COMM_PCAT_CTV INTO ZGUID

WHERE PARENT_CATEGORY = YGUID.

ENDIF.

  • ENDIF.

  • ENDLOOP.

BASIC_TEXT-TDOBJECT = 'PCAT_CTY'.

BASIC_TEXT-TDNAME = ZGUID.

BASIC_TEXT-TDID = '0001'.

BASIC_TEXT-TDSPRAS = 'EN'.

APPEND BASIC_TEXT.

CLEAR BASIC_TEXT.

BASICTEXT-TDFORMAT = '*'.

BASICTEXT-TDLINE = IT_SERENA-TEXT.

APPEND BASICTEXT.

CLEAR BASICTEXT.

data: thead1 like thead occurs 0 with header line.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = BASIC_TEXT

  • INSERT = ' '

SAVEMODE_DIRECT = 'X'

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

IMPORTING

  • FUNCTION =

NEWHEADER = thead1

TABLES

LINES = BASICTEXT

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • OBJECT = 4

  • OTHERS = 5

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDLOOP.

Some times it got exicuted..some times it is giving error like "text Object is not available".may be some problem in SAVE_TEXT.

In thede bugging i am getting every thin correct i am getting values for BASIC_TEXT BASICTEXT..in SAVE_TEXT FM.

But i am not getting values in Thead1 after exicuting SAVE_TEXT.

can any body guess what may be the problem?

I am sure of reward points.