Skip to Content
avatar image
Former Member

bdc interview question

hi,

How to use session method log file in call transaction method?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jan 02, 2008 at 06:46 AM

    Hi,

    Purpose of log file in session method can be achieved in Call Transaction method through Messages tab (of type BDCMSGCOLL) . Apart from this there is no direct relation between log file of session method and call transaction method.

    Thanks,

    Vinny

    Note: Dont get confused by invterviewers.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 02, 2008 at 11:49 AM

    Hi,

    refer the below code, which will give you clear picture how the handle the log messages in call transaction.

    &----


    *& Report ZDEV_BDC_MM01 *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT ZDEV_BDC_MM01 .

    DATA : BEGIN OF IT_DATA OCCURS 0,

    DATA(255),

    END OF IT_DATA .

    data : begin of it_MAT occurs 0,

    MATNR like RMMG1-MATNR,

    MBRSH LIKE RMMG1-MBRSH,

    MTART LIKE RMMG1-MTART,

    MAKTX LIKE MAKT-MAKTX,

    MEINS LIKE MARA-MEINS,

    end of it_MAT.

    DATA : BEGIN OF IT_ERROR OCCURS 0,

    MATNR LIKE MARA-MATNR,

    MESS(255),

    END OF IT_ERROR.

    DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

    IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,

    V_TEXT(200).

    PERFORM UPLOAD.

    LOOP AT IT_DATA.

    PERFORM POP_MAT.

    ENDLOOP.

    LOOP AT IT_MAT.

    PERFORM POP_BDCDATA.

    REFRESH IT_BDCMSGCOLL.

    CLEAR IT_BDCMSGCOLL.

    CALL TRANSACTION 'MM01' USING IT_BDCDATA

    UPDATE 'S'

    MODE 'N'

    MESSAGES INTO IT_BDCMSGCOLL.

    IF SY-SUBRC <> 0.

    LOOP AT IT_BDCMSGCOLL WHERE MSGTYP = 'E' OR

    MSGTYP = 'A' OR

    MSGTYP = 'S'.

    CALL FUNCTION 'FORMAT_MESSAGE'

    EXPORTING

    ID = IT_BDCMSGCOLL-MSGID

    LANG = sy-langu

    NO = IT_BDCMSGCOLL-MSGNR

    V1 = IT_BDCMSGCOLL-MSGV1

    V2 = IT_BDCMSGCOLL-MSGV2

    V3 = IT_BDCMSGCOLL-MSGV3

    V4 = IT_BDCMSGCOLL-MSGV4

    IMPORTING

    MSG = V_TEXT

    • EXCEPTIONS

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

    concatenate IT_ERROR-MESS V_TEXT INTO IT_ERROR-MESS.

    ENDLOOP.

    IT_ERROR-MATNR = IT_MAT-MATNR.

    APPEND IT_ERROR.

    CLEAR IT_ERROR.

    ENDIF.

    ENDLOOP.

    LOOP AT IT_ERROR.

    WRITE : IT_ERROR-MATNR, it_error-mess.

    ENDLOOP.

    &----


    *& Form UPLOAD

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM UPLOAD .

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    FILENAME = 'D:\MM01_DATA.TXT'

    FILETYPE = 'ASC'

    • HAS_FIELD_SEPARATOR = ','

    • HEADER_LENGTH = 0

    • READ_BY_LINE = 'X'

    • DAT_MODE = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • CHECK_BOM = ' '

    • IMPORTING

    • FILELENGTH =

    • HEADER =

    TABLES

    DATA_TAB = IT_DATA

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

    &----


    *& Form POP_MAT

    &----


    • text

    ----


    FORM POP_MAT .

    SPLIT IT_DATA AT ',' INTO IT_MAT-MATNR

    IT_MAT-MBRSH

    IT_MAT-MTART

    IT_MAT-MAKTX

    IT_MAT-MEINS.

    APPEND IT_MAT.

    CLEAR IT_MAT.

    ENDFORM. " POP_BDCDATA

    &----


    *& Form POP_BDCDATA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM POP_BDCDATA .

    REFRESH IT_BDCDATA.

    CLEAR IT_BDCDATA.

    PERFORM FILL_SCREEN USING 'SAPLMGMM' '0060' 'X'.

    PERFORM FILL_VALUS USING 'RMMG1-MATNR' IT_MAT-MATNR.

    PERFORM FILL_VALUS USING 'RMMG1-MBRSH' IT_MAT-MBRSH.

    PERFORM FILL_VALUS USING 'RMMG1-MTART' IT_MAT-MTART.

    PERFORM FILL_VALUS USING 'BDC_OKCODE' '=ENTR'.

    PERFORM FILL_SCREEN USING 'SAPLMGMM' '0070' 'X'.

    PERFORM FILL_VALUS USING 'MSICHTAUSW-KZSEL(01)' 'X'.

    PERFORM FILL_VALUS USING 'BDC_OKCODE' '=ENTR'.

    PERFORM FILL_SCREEN USING 'SAPLMGMM' '4004' 'X'.

    PERFORM FILL_VALUS USING 'MAKT-MAKTX' IT_MAT-MAKTX.

    PERFORM FILL_VALUS USING 'MARA-MEINS' IT_MAT-MEINS.

    PERFORM FILL_VALUS USING 'BDC_OKCODE' '=BU'.

    ENDFORM. " POP_BDCDATA

    &----


    *& Form FILL_SCREEN

    &----


    • text

    ----


    • -->P_0112 text

    • -->P_0113 text

    • -->P_0114 text

    ----


    FORM FILL_SCREEN USING P_PROG

    P_DYNPRO

    P_DYNBEGIN.

    IT_BDCDATA-PROGRAM = P_PROG.

    IT_BDCDATA-DYNPRO = P_DYNPRO.

    IT_BDCDATA-DYNBEGIN = P_DYNBEGIN.

    APPEND IT_BDCDATA.

    CLEAR IT_BDCDATA.

    ENDFORM. " FILL_SCREEN

    &----


    *& Form FILL_VALUS

    &----


    • text

    ----


    • -->P_0118 text

    • -->P_IT_MAT_MATNR text

    ----


    FORM FILL_VALUS USING P_FNAM

    P_FVAL.

    IT_BDCDATA-FNAM = P_FNAM.

    IT_BDCDATA-FVAL = P_FVAL.

    APPEND IT_BDCDATA.

    CLEAR IT_BDCDATA.

    ENDFORM. " FILL_VALUS

    Reward if useful.

    Thanks,

    Sreeram.

    Add comment
    10|10000 characters needed characters exceeded