Skip to Content
avatar image
Former Member

bdc

can u hav both call n session method in one program if yes then how ....

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Aug 17, 2007 at 04:17 PM

    Hi Rohan,

    yes we have..

    just check in the forum it has been posted number of times,,,,,,,

    y again ur posting

    See friend before posting just check its available r not

    Reward points if these points worthful.

    Thanks

    Naveen khan

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 17, 2007 at 04:27 PM

    for this type of requirement take 2 radio buttons based on the radio button requirement write the code(or) if you do recording when u see the coding there you find one <b>include BDCRECX1</b>.it generates default selection-screen regarding both methods.

    <b>reward points if helpful.</b>

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 18, 2007 at 06:51 AM

    see this sample code with both call transaction and session methods

    DATA : BEGIN OF ITAB OCCURS 0,

    EMPID LIKE ZNNR-EMPID,

    EMPNAME LIKE ZNNR-EMPNAME,

    EMPADR LIKE ZNNR-EMPADR,

    END OF ITAB.

    DATA : BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    FILENAME = 'C:\NARESH\NARESH.TXT'

    • FILETYPE = 'ASC'

    HAS_FIELD_SEPARATOR = 'X'

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

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

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

    ENDIF.

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING

    CLIENT = SY-MANDT

    • DEST = FILLER8

    GROUP = 'NARESH'

    • HOLDDATE = FILLER8

    KEEP = 'X'

    USER = SY-UNAME

    • RECORD = FILLER1

    • PROG = SY-CPROG

    • IMPORTING

    • QID =

    EXCEPTIONS

    CLIENT_INVALID = 1

    DESTINATION_INVALID = 2

    GROUP_INVALID = 3

    GROUP_IS_LOCKED = 4

    HOLDDATE_INVALID = 5

    INTERNAL_ERROR = 6

    QUEUE_ERROR = 7

    RUNNING = 8

    SYSTEM_LOCK_ERROR = 9

    USER_INVALID = 10

    OTHERS = 11

    .

    IF SY-SUBRC <> 0.

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

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

    ENDIF.

    LOOP AT ITAB.

    REFRESH BDCDATA.

    PERFORM BDC_DYNPRO USING 'ZNNR_MODULE' '0100'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'ZNNR-EMPADR'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '=CRT'.

    PERFORM BDC_FIELD USING 'ZNNR-EMPID'

    ITAB-EMPID.

    PERFORM BDC_FIELD USING 'ZNNR-EMPNAME'

    ITAB-EMPNAME.

    PERFORM BDC_FIELD USING 'ZNNR-EMPADR'

    ITAB-EMPADR.

    • PERFORM BDC_TRANSACTION USING 'ZNNC'.

    CALL FUNCTION 'BDC_INSERT'

    EXPORTING

    TCODE = 'ZNNC'

    • POST_LOCAL = NOVBLOCAL

    • PRINTING = NOPRINT

    • SIMUBATCH = ' '

    • CTUPARAMS = ' '

    TABLES

    DYNPROTAB = BDCDATA

    EXCEPTIONS

    INTERNAL_ERROR = 1

    NOT_OPEN = 2

    QUEUE_ERROR = 3

    TCODE_INVALID = 4

    PRINTING_INVALID = 5

    POSTING_INVALID = 6

    OTHERS = 7

    .

    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.

    CALL FUNCTION 'BDC_CLOSE_GROUP'

    EXCEPTIONS

    NOT_OPEN = 1

    QUEUE_ERROR = 2

    OTHERS = 3

    .

    IF SY-SUBRC <> 0.

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

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

    ENDIF.

    WRITE :/ 'SESSION CREATED SUCCESSFULLY'.

    FORM BDC_DYNPRO USING PROGRAM DYNPRO.

    CLEAR BDCDATA.

    BDCDATA-PROGRAM = PROGRAM.

    BDCDATA-DYNPRO = DYNPRO.

    BDCDATA-DYNBEGIN = 'X'.

    APPEND BDCDATA.

    ENDFORM.

    FORM BDC_FIELD USING FNAM FVAL.

    • IF FVAL <> NODATA.

    CLEAR BDCDATA.

    BDCDATA-FNAM = FNAM.

    BDCDATA-FVAL = FVAL.

    APPEND BDCDATA.

    • ENDIF.

    ENDFORM.

    regards,

    srinivas

    <b>*reward for useful answers*</b>

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 18, 2007 at 10:48 AM

    Hi,

    Yes you can use both call transaction and session in one program. Ideally we do so if we want to process the record afterwards or give session to the user containing only error records to process at a later point of time.

    Call transaction .....

    if sy-subrc ne 0.

    bdc_insert......

    endif.

    See the below code...particularly in between *********

    DATA : BEGIN OF itab OCCURS 0,
    empid LIKE znnr-empid,
    empname LIKE znnr-empname,
    empadr LIKE znnr-empadr,
    END OF itab.
    
    DATA : bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
    
    
    
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'C:NARESHNARESH.TXT'
    * FILETYPE = 'ASC'
    has_field_separator = 'X'
    * 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 <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    client = sy-mandt
    * DEST = FILLER8
    group = 'NARESH'
    * HOLDDATE = FILLER8
    keep = 'X'
    user = sy-uname
    * RECORD = FILLER1
    * PROG = SY-CPROG
    * IMPORTING
    * QID =
    EXCEPTIONS
    client_invalid = 1
    destination_invalid = 2
    group_invalid = 3
    group_is_locked = 4
    holddate_invalid = 5
    internal_error = 6
    queue_error = 7
    running = 8
    system_lock_error = 9
    user_invalid = 10
    OTHERS = 11
    .
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    
    LOOP AT itab.
    
      REFRESH bdcdata.
    
      PERFORM bdc_dynpro USING 'ZNNR_MODULE' '0100'.
      PERFORM bdc_field USING 'BDC_CURSOR'
      'ZNNR-EMPADR'.
      PERFORM bdc_field USING 'BDC_OKCODE'
      '=CRT'.
      PERFORM bdc_field USING 'ZNNR-EMPID'
      itab-empid.
      PERFORM bdc_field USING 'ZNNR-EMPNAME'
      itab-empname.
      PERFORM bdc_field USING 'ZNNR-EMPADR'
      itab-empadr.
    * PERFORM BDC_TRANSACTION USING 'ZNNC'.
    
    
    ***********************************************************************************************
    
    
      CALL TRANSACTION 'ZNNC' USING bdcdata MODE 'N' UPDATE 'S'.
      IF  sy-subrc NE 0.
    
        CALL FUNCTION 'BDC_INSERT'
        EXPORTING
        tcode = 'ZNNC'
    * POST_LOCAL = NOVBLOCAL
    * PRINTING = NOPRINT
    * SIMUBATCH = ' '
    * CTUPARAMS = ' '
        TABLES
        dynprotab = bdcdata
        EXCEPTIONS
        internal_error = 1
        not_open = 2
        queue_error = 3
        tcode_invalid = 4
        printing_invalid = 5
        posting_invalid = 6
        OTHERS = 7
        .
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    
      ENDIF.
    
    **********************************************************************************************
    ENDLOOP.
    
    CALL FUNCTION 'BDC_CLOSE_GROUP'
      EXCEPTIONS
        not_open    = 1
        queue_error = 2
        OTHERS      = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    
    
    WRITE :/ 'SESSION CREATED SUCCESSFULLY'.
    
    *&---------------------------------------------------------------------*
    *&      Form  BDC_DYNPRO
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->PROGRAM    text
    *      -->DYNPRO     text
    *----------------------------------------------------------------------*
    FORM bdc_dynpro USING program dynpro.
      CLEAR bdcdata.
      bdcdata-program = program.
      bdcdata-dynpro = dynpro.
      bdcdata-dynbegin = 'X'.
      APPEND bdcdata.
    ENDFORM.                    "BDC_DYNPRO
    
    *&---------------------------------------------------------------------*
    *&      Form  BDC_FIELD
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->FNAM       text
    *      -->FVAL       text
    *----------------------------------------------------------------------*
    FORM bdc_field USING fnam fval.
    * IF FVAL <> NODATA.
      CLEAR bdcdata.
      bdcdata-fnam = fnam.
      bdcdata-fval = fval.
      APPEND bdcdata.
    * ENDIF.
    ENDFORM.                    "BDC_FIELD
    

    Reward points if useful,

    Aleem.

    Add comment
    10|10000 characters needed characters exceeded