Вы находитесь на странице: 1из 16

11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE


SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE

Step by Step tutorial on BDC Session Method


Program in SAP ABAP
June 20, 2017

Step by Step tutorial on BDC Session Method


Program in SAP ABAP
BDC Session Method is used to upload data from Non-SAP to SAP System
.Using Session method ,
we can transfer data through more than one Transaction Unlike BDC Call
Transaction Method Program .

We are Processing Batch input Session From SM35 Transaction Code .

Session method.
1) synchronous processing.
2) can tranfer large amount of data.
3) processing is slower.
4) error log is created
5) data is not updated until session is processed.

Call transaction Method.


https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 1/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

1) asynchronous processing
2)SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE
can transfer small amount of data
3) processing is faster.
4) errors need to be handled explicitly
5) data is updated automatically

Go to SHDB and Press Enter

Click on New Recording Button and Give the zrecord1 name and enter
transaction code MM01 and click on Start recording button.

Select Topics

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 2/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

System goes to the Create material screen ,there give the industry sector
SAP ABAPandAND WEBDYNPRO
material TUTORIALS
type and select basic data 1. SUBSCRIBE

Now it will come to second screen where give the below details and click on
save button and go back

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 3/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE


Now save the recording and go back.

Now ,select created record ,click on program button

System will ask you program name ,give it and continue .

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 4/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE

Now give the program title and continue

Now double click on BDCRECX1 main program 

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 5/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE

Copy the below code.

BDC Session Method Program

report ZSESSION_PROGRAM
       no standard page heading line-size 255.

TYPES : BEGIN OF ty_mat,


          mbrsh TYPE mbrsh,
          mtart TYPE mtart,
          maktx TYPE maktx,
          matkl TYPE matkl,
          meins TYPE meins,
        END OF ty_mat.

DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.


https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 6/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP
DATA: BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.

SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE


DATA:
        f_name   TYPE rlgrap- lename,
        it_mat   TYPE STANDARD TABLE OF ty_mat,
        wa_mat   TYPE ty_mat.

*Input Path
PARAMETERS:
  p_ le   TYPE rlgrap- lename. " File Path

* Data decleration
DATA:
  wa_path TYPE string ,
  wa_error TYPE string,
  wa_cnt   TYPE i,
  w_mode    TYPE c,
  wa_cnt1(2) TYPE n.

* Opening window for path selection

at SELECTION-SCREEN on VALUE-REQUEST FOR p_ le.


    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
       eld_name    = ' '
    IMPORTING
       le_name     = p_ le.

  TYPES:
    fs_struct(4096) TYPE c OCCURS 0 .

  DATA:
    w_struct TYPE fs_struct.

* Uploading excel file.


  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
i eld seperator = 'X'
https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 7/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP
      i_ eld_seperator          = 'X'
*SAP ABAP AND WEBDYNPRO
I_LINE_HEADER = TUTORIALS SUBSCRIBE
      i_tab_raw_data             = w_struct
      i_ lename                 = p_ le
    TABLES
      i_tab_converted_data       = it_mat
    EXCEPTIONS
      conversion_failed          = 1
      OTHERS = 2
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

start-of-selection.

  CALL FUNCTION 'BDC_OPEN_GROUP'


    EXPORTING
      CLIENT = SY-MANDT
      GROUP = 'AKS'
      KEEP                = 'X'
      USER                = SY-UNAME
    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.

START-OF-SELECTION.
  LOOP AT it_mat INTO wa_mat.

    perform bdc_dynpro      using 'SAPLMGMM' '0060'.


https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 8/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

    perform bdc_ eld       using 'BDC_CURSOR'


SAP ABAP 'RMMG1-MTART'.
                                   AND WEBDYNPRO TUTORIALS SUBSCRIBE

    perform bdc_ eld       using 'BDC_OKCODE'


                                  '/00'.
    perform bdc_ eld       using 'RMMG1-MBRSH'
                                  wa_mat-mbrsh."record-MBRSH_001.
    perform bdc_ eld       using 'RMMG1-MTART'
                                  wa_mat-mtart."record-MTART_002.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_ eld       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    perform bdc_ eld       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_ eld       using 'MSICHTAUSW-KZSEL(01)'
                                  'X'."record-KZSEL_01_003.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_ eld       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_ eld       using 'MAKT-MAKTX'
                                  wa_mat-maktx."record-MAKTX_004.
    perform bdc_ eld       using 'BDC_CURSOR'
                                  'MARA-MATKL'.
    perform bdc_ eld       using 'MARA-MEINS'
                                  wa_mat-meins."record-MEINS_005.
    perform bdc_ eld       using 'MARA-MATKL'
                                  wa_mat-matkl."record-MATKL_006.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_ eld       using 'BDC_OKCODE'
                                  '=YES'.

    CALL FUNCTION 'BDC_INSERT'


     EXPORTING
       TCODE                  = 'MM01'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
      TABLES
        DYNPROTAB              = BDCDATA
EXCEPTIONS
https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 9/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP
     EXCEPTIONS
       INTERNAL_ERROR         = 1
SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE
       NOT_OPEN               = 2
       QUEUE_ERROR            = 3
       TCODE_INVALID          = 4
       PRINTING_INVALID       = 5
       POSTING_INVALID        = 6
       OTHERS = 7
              .
    REFRESH BDCDATA.
  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.
*-----------------------------------------------------------
-----------*
* Start new screen
*
*-----------------------------------------------------------
-----------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
  CLEAR BDCDATA.
  BDCDATA-PROGRAM = PROGRAM.
  BDCDATA-DYNPRO = DYNPRO.
  BDCDATA-DYNBEGIN = 'X'.
  APPEND BDCDATA .
ENDFORM. "BDC_DYNPRO

*-----------------------------------------------------------
-----------*
* Insert field
*

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 10/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP
*-----------------------------------------------------------
SAP ABAP AND WEBDYNPRO TUTORIALS
-----------* SUBSCRIBE
FORM BDC_FIELD USING FNAM FVAL.

  CLEAR BDCDATA.
  BDCDATA-FNAM = FNAM.
  BDCDATA-FVAL = FVAL.
  APPEND BDCDATA .

ENDFORM. "BDC_FIELD

Now save and activate the program and execute it,then go to SM35.
and also maintain the excell sheet data like below and save it in your
system.

Then give the le path through F4 HELP and click on execute button.

Now go to the SM35 Transaction code .and click on Process button.

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 11/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE

Select Process fore ground button.

Now ,you can see the session log details.

Click on analyse session button to get more details 

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 12/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE


Finally ,we successfully created the  BDC Session Method Program.
How to Start SAP ABAP Course

RELATED POSTS:

SAP ABAP How To Pass How To De ne


Material And Selection-Screen SAP ABAP ALV
Tutorials Inform... Report O...

BDC Recording In
SAP ABAP

Related Posts Widget BDC SAP ABAP

Enter your comment...

Popular ABAP Tutorials

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 13/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP
SAPABAP Data AND
ABAP Dictionary Real Time Interview
WEBDYNPRO TUTORIALS SUBSCRIBE
Questions and Aanswers
April 11, 2017

SAP ABAP Data Dictionary Real Time Interview Questions and Answers
These interview Questions from the SAP ABAP Data Dictionary are faced at
the different companies in the several interviews which are useful for real …

KEEP READING

BADI Interview Questions in SAP


April 13, 2017

BADI Interview Questions in SAP A BAdI is an object-oriented


enhancement option, which makes it the most sophisticated enhancement
type. The main characteristic of a BAdI is that it provides a mechanism to …

KEEP READING

SAP ABAP Smartforms Interview Questions and


Answers
April 13, 2017

SAP ABAP Smartforms Interview Questions and Answers

What is smartform? Smart Forms are printing forms used to print Invoice …

KEEP READING

Sample ABAP Programming Examples for Practice


July 16, 2017

Sample ABAP Programming Examples for Practice Are you beginner to


ABAP Language ,you're looking for example programs for practice .Here i
collected some sample programs from various objects in ABAP useful for …

KEEP READING

ALV Reports Interview Questions


https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 14/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

April 12, 2017


SAP ABAP AND WEBDYNPRO TUTORIALS SUBSCRIBE

SAP ABAP ALV Reports Interview Questions and Answers for Experienced 


Here, i am sharing very import real time oriented questions which are faced
at several interviews on ALV Reports to help for freshers and experienced …

KEEP READING

Like on Facebook

SAP ABAP and WebD…


967 likes

Like Page Share

Be the first of your friends to like this

Donate to Me

Donate with PayPal

Powered by Blogger

Theme images by Michael Elkan

Labels

Monthly Updates

Report Abuse

Privacy Policy

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 15/16
11/20/2019 Step by Step tutorial on BDC Session Method Program in SAP ABAP

https://sinuabaptutor.blogspot.com/2017/06/tutorial-on-bdc-session-method-sap-abap.html 16/16

Вам также может понравиться