Monday, February 17, 2020

How to create ODATA Service with association in SAP ABAP.


How to create ODADA service with association in SAP ABAP.

ODATA service creation details.


Go to T-code:-  SEGW
Create new project.
Insert project name, description and package name.

 
The name of the Project: NGS_104_CAMP and the Description: Campaign Project.
After creating the project right click on data model and import DDIC structure.

 
We have uploaded two structures here which were created in se11.

First is zcampcc.

Second is zcustcc.


Repeat the same process for zcustcc.
By selecting the checkbox Create default entity set, it will automatically create the entity set.

As shown below after importing the structure entity sets zcampccset and zcustccset are created.

 
The fields in zcampcc are as shown below.

Here the field column shows the name of the components in structure and the name column indicates the name in odata.

 

The fields of zcustcc are as shown below.


After uploading the structure.

Check the project consistency and generate runtime time objects(red color ball like icon).

If It shows warnings neglect that.





Go to service maintains, select the server which you are working with:

Select the register service button.

Enter the name of the package and select next.

Your project has been registered.

 


Go to runtime an artifact which contains the data provider and model provider class.
Here ZCL_ZNGS_104_CAMP_DPC_EXT is the data provider class.

And ZCL_ZNGS_104_CAMP_MPC_EXT is the model provider class.

Right click on the data provider class and select go to Abap workbench.

 
Go to inherited methods and you will see every uploaded structure will have five in build methods in inherited methods which are: ZCAMPCCSET_CREATE_ENTITY, ZCAMPCCSET_DELETE_ENTITY, ZCAMPCCSET_GET_ENTITY, ZCAMPCCSET_GET_ENTITYSET, ZCAMPCCSET_UPDATE_ENTITY   and same would be for zcustcc.
Right click on ZCAMPCCSET_GET_ENTITYSET and click redefinition.
Now this method will be shown in redefinition folder.

 
Now copy paste the below code in each method:
Activate each method after copying the code.
·         Zcamp_get _entityset.
    METHOD ZCAMPCCSET_GET_ENTITYSET.
  
DATAIT_CAMP TYPE TABLE OF ZCAMPCC,
        WA_CAMP 
LIKE LINE OF IT_CAMP,
        WA_ENTITY 
LIKE LINE OF ET_ENTITYSET.
*Get data from ZCAMPAIGN_DEMO table
  
SELECT FROM ZCAMPCC INTO TABLE IT_CAMP.
*FILL ET_ENTITYSET
  
LOOP AT IT_CAMP INTO WA_CAMP.
    
MOVE-CORRESPONDING WA_CAMP TO WA_ENTITY.
    
APPEND WA_ENTITY TO ET_ENTITYSET.
  
ENDLOOP.
ENDMETHOD.
·         Zcamp_get_entity.
METHOD ZCAMPCCSET_GET_ENTITY.
  
DATALS_KEY_TAB LIKE LINE OF IT_KEY_TAB,"TYPE /IWBEP/T_MGW_NAME_VALUE_PAIR,
        LV_ID 
TYPE ZCAMPCC-C_ID,
        WA_COMP 
TYPE ZCAMPCC.

*Get the key property values
  
READ TABLE IT_KEY_TAB WITH KEY NAME 'CId' INTO LS_KEY_TAB.
  LV_ID 
LS_KEY_TAB-VALUE.

*Get the single record from ZCAMPAIGN_DEMO and fill er_entity

  
SELECT SINGLE FROM ZCAMPCC INTO WA_COMP WHERE C_ID LV_ID.
  
IF SY-SUBRC 0.
    
MOVE-CORRESPONDING WA_COMP TO ER_ENTITY.
  
ENDIF.
·         Zcamp_create_entity

METHOD ZCAMPCCSET_CREATE_ENTITY.

  
DATALS_REQUEST_INPUT_DATA TYPE ZCL_ZNGS_104_CAMP_MPC=>TS_ZCAMPCC,
        WA_COMP 
TYPE ZCAMPCC.
* Read Request Data
  IO_DATA_PROVIDER
->READ_ENTRY_DATAIMPORTING ES_DATA LS_REQUEST_INPUT_DATA ).
* Fill workarea to be inserted
  
MOVE-CORRESPONDING LS_REQUEST_INPUT_DATA TO WA_COMP.
* Insert Data in table ZUSERINFO
  
INSERT ZCAMPCC FROM WA_COMP.
  
IF SY-SUBRC 0.
    ER_ENTITY 
LS_REQUEST_INPUT_DATA"Fill Exporting parameter ER_ENTITY
  
ENDIF.

·         Zcamp_update_entity

DATA:   LS_REQUEST_INPUT_DATA TYPE ZCL_ZNGS_104_CAMP_MPC=>TS_ZCAMPCC,
          LS_KEY_TAB        
LIKE LINE OF IT_KEY_TAB,
          LV_ID             
TYPE ZCAMPCC-C_ID,
          WA_COMP           
TYPE ZCAMPCC.
* Get key values
  
READ TABLE IT_KEY_TAB WITH KEY NAME 'CId' INTO LS_KEY_TAB.
  LV_ID 
LS_KEY_TAB-VALUE.
  
IF LV_ID IS NOT INITIAL.

* Read request data
    IO_DATA_PROVIDER
->READ_ENTRY_DATAIMPORTING ES_DATA LS_REQUEST_INPUT_DATA ).

* Update fields of table ZUSERINFO
    
UPDATE ZCAMPCC SET        C_NAME  LS_REQUEST_INPUT_DATA-C_NAME
                              C_TYPE    
LS_REQUEST_INPUT_DATA-C_TYPE
                              C_GRP     
LS_REQUEST_INPUT_DATA-C_GRP
                              C_TCUST  
LS_REQUEST_INPUT_DATA-C_TCUST
                              C_EXE    
'X'""LS_REQUEST_INPUT_DATA-C_EXE'
                          
WHERE C_ID  LV_ID.
    
IF SYSUBRC 0.
      ER_ENTITY LS_REQUEST_INPUT_DATA"Fill exporting parameter ER_
  
else.
    er_entity
-c_err 'Error in Update'.
    ENDIF.

·         Zcamp_delete_entity.

METHOD ZCAMPCCSET_DELETE_ENTITY.

  
DATA:  LS_KEY_TAB LIKE LINE OF IT_KEY_TAB,
        LV_ID 
TYPE ZCAMPCC-C_ID.

* Read key values
  
READ  TABLE IT_KEY_TAB INTO LS_KEY_TAB WITH KEY NAME 'CId'.
  LV_ID 
LS_KEY_TAB-VALUE.
  
IF LV_ID IS NOT INITIAL.
* Delete record from table ZUSERINFO
    
DELETE FROM ZCAMPCC WHERE C_ID LV_ID.
  
ENDIF.

ENDMETHOD.



Zcust_get_entityset.
 DATAIT_COMP TYPE TABLE OF ZCUSTCC,
        WA_COMP 
LIKE LINE OF IT_COMP,
        WA_ENTITY 
LIKE LINE OF ET_ENTITYSET.

*Get data from ZCAMPAIGN_DEMO table
  
SELECT FROM ZCUSTCC INTO TABLE IT_COMP.

*FILL ET_ENTITYSET
  
LOOP AT IT_COMP INTO WA_COMP.
    WA_ENTITY
-CUST_ID WA_COMP-CUST_ID.
    WA_ENTITY
-CUST_NAME WA_COMP-CUST_NAME.
    WA_ENTITY
-CUST_EID WA_COMP-CUST_EID.
    WA_ENTITY
-C_GRP WA_COMP-C_GRP.
    WA_ENTITY
-C_TYPE WA_COMP-C_TYPE.


    
APPEND WA_ENTITY TO ET_ENTITYSET.
  
ENDLOOP.
Zcust_get_entity.
DATALS_KEY_TAB LIKE LINE OF IT_KEY_TAB,"TYPE /IWBEP/T_MGW_NAME_VALUE_PAIR,
        LV_ID 
TYPE ZCUSTCC-CUST_ID,
        WA_COMP 
TYPE ZCUSTCC.

*Get the key property values
  
READ TABLE IT_KEY_TAB WITH KEY NAME 'CustId' INTO LS_KEY_TAB.
  LV_ID 
LS_KEY_TAB-VALUE.

*Get the single record from ZCAMPAIGN_DEMO and fill er_entity

  
SELECT SINGLE FROM ZCUSTCC INTO WA_COMP WHERE CUST_ID LV_ID.
  
IF SY-SUBRC 0.
    MOVE-CORRESPONDING WA_COMP TO ER_ENTITY.
  ENDIF.
Zcust_create_entity.
  DATALS_REQUEST_INPUT_DATA TYPE ZCL_ZNGS_104_CAMP_MPC=>TS_ZCUSTCC,
       WA_COMP 
TYPE ZCUSTCC.

* Read Request Data
  IO_DATA_PROVIDER
->READ_ENTRY_DATAIMPORTING ES_DATA LS_REQUEST_INPUT_DATA ).

* Fill workarea to be inserted
  
MOVE-CORRESPONDING LS_REQUEST_INPUT_DATA TO WA_COMP.
* Insert Data in table ZUSERINFO
  
INSERT ZCUSTCC FROM WA_COMP.
  
IF SY-SUBRC 0.
    ER_ENTITY 
LS_REQUEST_INPUT_DATA"Fill Exporting parameter ER_ENTITY
  
ENDIF.
Zcust_update_entity.
DATA:  LS_REQUEST_INPUT_DATA TYPE ZCL_ZNGS_104_CAMP_MPC=>TS_ZCUSTCC ,
         LS_KEY_TAB            
LIKE LINE OF IT_KEY_TAB,
         LV_ID             
TYPE ZCUSTCC-CUST_ID,
         WA_COMP           
TYPE ZCUSTCC.
* Get key values
  
READ TABLE IT_KEY_TAB WITH KEY NAME 'CustId' INTO LS_KEY_TAB.
  LV_ID 
LS_KEY_TAB-VALUE.
  
IF LV_ID IS NOT INITIAL.

* Read request data
    IO_DATA_PROVIDER
->READ_ENTRY_DATAIMPORTING ES_DATA LS_REQUEST_INPUT_DATA ).

* Update fields of table ZUSERINFO
    
UPDATE ZCUSTCC SET           CUST_ID LS_REQUEST_INPUT_DATA-CUST_ID
                                 CUST_NAME  
LS_REQUEST_INPUT_DATA-CUST_NAME
                                 CUST_EID  
LS_REQUEST_INPUT_DATA-CUST_EID
                                 C_TYPE    
LS_REQUEST_INPUT_DATA-C_TYPE
                                 C_GRP     
LS_REQUEST_INPUT_DATA-C_GRP
                          
WHERE  CUST_ID  LV_ID.
    
IF SY-SUBRC 0.
      ER_ENTITY 
LS_REQUEST_INPUT_DATA"Fill exporting parameter ER_ENTITY
    
ENDIF.
  
ENDIF.
Zcust_delete_entity.
 DATA:  LS_KEY_TAB LIKE LINE OF IT_KEY_TAB,
      LV_ID 
TYPE ZCUSTCC-CUST_ID.

* Read key values
  
READ  TABLE IT_KEY_TAB INTO LS_KEY_TAB WITH KEY NAME 'CustId'.
  LV_ID 
LS_KEY_TAB-VALUE.
  
IF LV_ID IS NOT INITIAL.
* Delete record from table ZUSERINFO
    
DELETE FROM ZCUSTCC WHERE CUST_ID LV_ID.
  
ENDIF.

For Creating association :

Go to association folder and right click and click create.

Fill the following details as shown below.

 
If your structure has same key fields then select the principal key and dependent proprety as same field.
Click next.

 
Select Finish.

 

To run this project go to gateway client.

 



The Below URI will call Zcampccset_get_entityset method. 
/sap/opu/odata/SAP/ZNGS_104_CAMP_SRV/zcampccSet
/sap/opu/odata/SAP/ZNGS_104_CAMP_SRV/zcustccSet
_________________________________________________________________________________

/sap/opu/odata/SAP/ZNGS_104_CAMP_SRV/zcampccSet?$expand=camptocustrel
The above uri is for association.
The Below image shows the final tree of the project ZNgs_104_camp.
 

XK01 BDC Program in SAP ABAP.


XK01 BDC Program in SAP ABAP.

REPORT  zrk_bdc_xk01_calltra NO STANDARD PAGE HEADING.
include zrk_bdc_xk01_calltra_top.
include zrk_bdc_xk01_calltra_sel.
include zrk_bdc_xk01_calltra_f01.

*----------------------------------------------------------------------*
* Initialization Event
*----------------------------------------------------------------------*
INITIALIZATION.
PERFORM f_defualt_values.

*----------------------------------------------------------------------*
* At Selection Screen Event
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f_get_file.

START-OF-SELECTION.
PERFORM data_upload.
PERFORM get_bdc.


======================================================================================
TOP 
======================================================================================
*&---------------------------------------------------------------------*
*&  Include           ZRK_BDC_XK01_CALLTRA_TOP
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
*&---------------------------------------------------------------------*
*& Internal Table Declaration
*&---------------------------------------------------------------------*
DATA:BEGIN OF i_tab OCCURS 0,
  bukrs TYPE  rf02k-bukrs,
  ekorg TYPE  rf02k-ekorg,
  ktokk TYPE  rf02k-ktokk,
  anred TYPE  lfa1-anred,
  name1 TYPE  lfa1-name1,
  sortl TYPE  lfa1-sortl,
  land1 TYPE  lfa1-land1,
  akont TYPE  lfb1-akont,
  fdgrv TYPE  lfb1-fdgrv,
  waers TYPE  lfm1-waers,
END OF i_tab.

*Structure for error message
TYPES : BEGIN OF ty_s_error,
  msg_err(60) TYPE C,
END OF ty_s_error.

DATA:
*      wa_path TYPE string ,
*      wa_error TYPE string,
*      wa_cnt   TYPE I,
*      w_mode    TYPE C,
*      wa_cnt1(2) TYPE n,
      it_output TYPE TABLE OF ty_s_error,
      wa_output LIKE LINE OF it_output.

=====================================================================
Selection Screen
=====================================================================
*&---------------------------------------------------------------------*
*&  Include           ZRK_BDC_XK01_CALLTRA_SEL
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Selection Screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text_001.
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(20) text_1_1.
    PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
  SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
====================================================================================
SUB Page
=====================================================================================
*&---------------------------------------------------------------------*
*&  Include           ZRK_BDC_XK01_CALLTRA_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  F_DEFUALT_VALUES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_defualt_values .
  text_001 = 'File path selection'.
  text_1_1 = 'File Path'.
ENDFORM.                    " F_DEFUALT_VALUES
*&---------------------------------------------------------------------*
*&      Form  F_GET_FILE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_get_file .
  CALL FUNCTION 'F4_FILENAME'
  IMPORTING
    file_name = p_file.

ENDFORM.                    " F_GET_FILE
*&---------------------------------------------------------------------*
*&      Form  DATA_UPLOAD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM data_upload .
  DATA: loc_filename TYPE string.
  loc_filename = p_file.

  CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                = loc_filename
    filetype                = 'DAT'
    has_field_separator     = 'X'
  TABLES
    data_tab                = i_tab
  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.                    " DATA_UPLOAD
*&---------------------------------------------------------------------*
*&      Form  GET_BDC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_bdc .
  IF i_tab[] IS NOT INITIAL.
    PERFORM open_group.
    LOOP AT i_tab.
      REFRESH bdcdata.
      PERFORM bdcdata.
    ENDLOOP.
    PERFORM close_group.
  ENDIF.
ENDFORM.                    " GET_BDC
*&---------------------------------------------------------------------*
*&      Form  OPEN_GROUP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM open_group .

ENDFORM.                    " OPEN_GROUP
*&---------------------------------------------------------------------*
*&      Form  BDCDATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM bdcdata .
*---->>> Insert Recording Here
  PERFORM bdc_dynpro      USING 'SAPMF02K' '0100'.
  PERFORM bdc_field       USING 'BDC_CURSOR'      'RF02K-KTOKK'.
  PERFORM bdc_field       USING 'BDC_OKCODE'      '/00'.
  PERFORM bdc_field       USING 'RF02K-BUKRS' i_tab-bukrs.      "     '1000'.
  PERFORM bdc_field       USING 'RF02K-EKORG' i_tab-ekorg.     "    '1000'.
  PERFORM bdc_field       USING 'RF02K-KTOKK' i_tab-ktokk.     "   '0001'.
  PERFORM bdc_dynpro      USING 'SAPMF02K'        '0110'.
  PERFORM bdc_field       USING 'BDC_CURSOR'      'LFA1-LAND1'.
  PERFORM bdc_field       USING 'BDC_OKCODE'      '/00'.
  PERFORM bdc_field       USING 'LFA1-ANRED' i_tab-anred.       "      'Mr'.
  PERFORM bdc_field       USING 'LFA1-NAME1' i_tab-name1.       "      'nageshpur'.
  PERFORM bdc_field       USING 'LFA1-SORTL' i_tab-sortl.       "      'NAGESH'.
  PERFORM bdc_field       USING 'LFA1-LAND1' i_tab-land1.       "     'IN'.
  PERFORM bdc_dynpro      USING 'SAPMF02K'        '0120'.
  PERFORM bdc_field       USING 'BDC_CURSOR'      'LFA1-KUNNR'.
  PERFORM bdc_field       USING 'BDC_OKCODE'      '/00'.
  PERFORM bdc_dynpro      USING 'SAPMF02K'       '0130'.
  PERFORM bdc_field       USING 'BDC_CURSOR'     'LFBK-BANKS(01)'.
  PERFORM bdc_field       USING 'BDC_OKCODE'     '=ENTR'.
  PERFORM bdc_dynpro      USING 'SAPMF02K'      '0380'.
  PERFORM bdc_field       USING 'BDC_CURSOR'    'KNVK-NAMEV(01)'.
  PERFORM bdc_field       USING 'BDC_OKCODE'    '=ENTR'.
  PERFORM bdc_dynpro      USING 'SAPMF02K'     '0210'.
  PERFORM bdc_field       USING 'BDC_CURSOR'   'LFB1-FDGRV'.
  PERFORM bdc_field       USING 'BDC_OKCODE'   '/00'.
  PERFORM bdc_field       USING 'LFB1-AKONT' i_tab-akont.          "   '31000'.
  PERFORM bdc_field       USING 'LFB1-FDGRV' i_tab-fdgrv.          "  'A1'.
  PERFORM bdc_dynpro      USING 'SAPMF02K'    '0215'.
  PERFORM bdc_field       USING 'BDC_CURSOR'  'LFB1-ZTERM'.
  PERFORM bdc_field       USING 'BDC_OKCODE'  '/00'.
  PERFORM bdc_dynpro      USING 'SAPMF02K'    '0220'.
  PERFORM bdc_field       USING 'BDC_CURSOR'  'LFB5-MAHNA'.
  PERFORM bdc_field       USING 'BDC_OKCODE'  '/00'.
  PERFORM bdc_dynpro      USING 'SAPMF02K'    '0310'.
  PERFORM bdc_field       USING 'BDC_CURSOR'  'LFM1-WAERS'.
  PERFORM bdc_field       USING 'BDC_OKCODE'  '=UPDA'.
  PERFORM bdc_field       USING 'LFM1-WAERS'  i_tab-waers.        " 'INR'.

  PERFORM bdc_insert.

ENDFORM.                    " BDCDATA
*&---------------------------------------------------------------------*
*&      Form  CLOSE_GROUP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM close_group .

ENDFORM.                    " CLOSE_GROUP
*&---------------------------------------------------------------------*
*&      Form  BDC_INSERT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM bdc_insert .

*Data decleration for Error Message
  DATA:
        t_msg TYPE TABLE OF bdcmsgcoll,   " Collecting Error messages
        w_msg TYPE bdcmsgcoll,
        w_msg1(51).

* Call transaction 'ME51'
  CALL TRANSACTION 'XK01' USING bdcdata
        MODE   'N'
        UPDATE 'S'
        MESSAGES INTO t_msg.

  IF sy-subrc EQ 0.
    LOOP AT t_msg INTO w_msg.
*    Uploaded into the database
      WRITE :/ 'Customer created successfully :', w_msg-msgv1.
    ENDLOOP.
  ELSE.
*    Error Found
    LOOP AT t_msg INTO w_msg WHERE msgtyp EQ 'E'.
*     Format Message
      CALL FUNCTION 'MESSAGE_TEXT_BUILD'
      EXPORTING
        msgid               = w_msg-msgid
        msgnr               = w_msg-msgnr
        msgv1               = w_msg-msgv1
        msgv2               = w_msg-msgv2
        msgv3               = w_msg-msgv3
        msgv4               = w_msg-msgv4
      IMPORTING
        message_text_output = w_msg1.


      wa_output-msg_err = w_msg1.

*Error message in downloaded file
      DATA:
            wa_string(10) TYPE C.
      CONCATENATE wa_string wa_output-msg_err INTO wa_output-msg_err SEPARATED BY space.
      APPEND wa_output-msg_err TO it_output.
      WRITE :/ 'Error in records', wa_output-msg_err.

    ENDLOOP.

  ENDIF.
ENDFORM.                    " BDC_INSERT
*&---------------------------------------------------------------------*
*&      Form  BDC_DYNPRO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0145   text
*      -->P_0146   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
*----------------------------------------------------------------------*
*      -->P_0150   text
*      -->P_0151   text
*----------------------------------------------------------------------*
FORM bdc_field  USING  fnam fval.
  CLEAR bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  APPEND bdcdata.
ENDFORM.                    " BDC_FIELD

MM01 BDC Program in SAP ABAP.

MM01 BDC Program in SAP ABAP.

*&---------------------------------------------------------------------*
*& Report  ZRK_BDC_MM01
*&---------------------------------------------------------------------*
*& Created By   :
*& Requested By :
*& Date         :
*& TR No.       :
*& TCode        :
*& Description  :
*&---------------------------------------------------------------------*
REPORT  zrk_bdc_mm01.
*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
*&---------------------------------------------------------------------*
*& Internal Table Declaration
*&---------------------------------------------------------------------*
DATA:BEGIN OF i_tab OCCURS 0,
     mbrsh TYPE rmmg1-mbrsh,
     mtart TYPE rmmg1-mtart,
     meins TYPE mara-meins,
     matkl TYPE mara-matkl,
     maktx TYPE makt-maktx,
    END OF i_tab.
*----------------------------------------------------------------------*
* Selection Screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text_001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text_1_1.
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
*----------------------------------------------------------------------*
* Initialization Event
*----------------------------------------------------------------------*
INITIALIZATION.
  text_001 = 'File path selection'.
  text_1_1 = 'File Path'.
*----------------------------------------------------------------------*
* At Selection Screen Event
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      file_name = p_file.
*&---------------------------------------------------------------------*
*& Start of Selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM data_upload.
  IF i_tab[] IS NOT INITIAL.
  PERFORM open_group.
    LOOP AT i_tab.
  REFRESH bdcdata.
  PERFORM bdcdata.
    ENDLOOP.
  PERFORM close_group.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  DATA_UPLOAD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM data_upload.
  DATA: loc_filename TYPE string.
  loc_filename = p_file.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = loc_filename
      filetype                = 'DAT'
      has_field_separator     = 'X'
    TABLES
      data_tab                = i_tab
    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.                    " DATA_UPLOAD

*----------------------------------------------------------------------*
*        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                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
  CLEAR bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  APPEND bdcdata.
ENDFORM.                    "BDC_FIELD

*&---------------------------------------------------------------------*
*&      Form  OPEN_GROUP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM open_group .
  CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
      client = sy-mandt
      group  = 'ZROHAN_MM01' "'Session_Name'
      user   = sy-uname
      keep   = 'X'.
ENDFORM.                    " OPEN_GROUP

*&---------------------------------------------------------------------*
*&      Form  CLOSE_GROUP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM close_group .
  CALL FUNCTION 'BDC_CLOSE_GROUP'.
  CALL TRANSACTION 'SM35'.
ENDFORM.                    " CLOSE_GROUP

*&---------------------------------------------------------------------*
*&      Form  bdcdata
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM bdcdata .
*---->>> Insert Recording Here
  PERFORM bdc_dynpro      USING 'SAPLMGMM' '0060'.
  PERFORM bdc_field       USING 'BDC_CURSOR' 'RMMG1-MATNR'.
  PERFORM bdc_field       USING 'BDC_OKCODE' '=ENTR'.
  PERFORM bdc_field       USING 'RMMG1-MBRSH' i_tab-mbrsh. "'P'.              " this fields
  PERFORM bdc_field       USING 'RMMG1-MTART' i_tab-mtart. "'ROH'.            " this fields
  PERFORM bdc_dynpro      USING 'SAPLMGMM' '0070'.
  PERFORM bdc_field       USING 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(02)'.
  PERFORM bdc_field       USING 'BDC_OKCODE' '=ENTR'.
  PERFORM bdc_field       USING 'MSICHTAUSW-KZSEL(01)' 'X'.
  PERFORM bdc_field       USING 'MSICHTAUSW-KZSEL(02)' 'X'.
  PERFORM bdc_dynpro      USING 'SAPLMGMM' '4004'.
  PERFORM bdc_field       USING 'BDC_OKCODE' '=SP02'.
  PERFORM bdc_field       USING 'BDC_CURSOR'  'MARA-MATKL'.
  PERFORM bdc_field       USING 'MARA-MEINS' i_tab-meins. "'KG'.                " unit of mesuremetns
  PERFORM bdc_field       USING 'MARA-MATKL' i_tab-matkl. "'00106'.             " baisc unit
  PERFORM bdc_dynpro      USING 'SAPLMGMM' '4004'.
  PERFORM bdc_field       USING 'BDC_OKCODE' '=BU'.
  PERFORM bdc_field       USING 'BDC_CURSOR' 'MAKT-MAKTX'.
  PERFORM bdc_field       USING 'MAKT-MAKTX' i_tab-maktx. "'Created by RHAN'.  " material descrption

  PERFORM bdc_insert.
ENDFORM.                    " bdcdata

*&---------------------------------------------------------------------*
*&      Form  bdc_insert
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM bdc_insert.
  CALL FUNCTION 'BDC_INSERT'
    EXPORTING
      tcode     = 'MM01' "'TCODE'
    TABLES
      dynprotab = bdcdata.
ENDFORM.                    " bdc_insert



File Structure :

P ROH KG 00106 Created by RAH1
P ROH KG 00106 Created by RAH2

XD01 BDC Program in SAP ABAP


XD01 BDC Program in SAP ABAP.

*&---------------------------------------------------------------------*
*& Report  ZRK_BDC_MM01
*&---------------------------------------------------------------------*
*& Created By   :
*& Requested By :
*& Date         :
*& TR No.       :
*& TCode        :
*& Description  :
*&---------------------------------------------------------------------*
REPORT  zrk_bdc_xd01.
*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
*&---------------------------------------------------------------------*
*& Internal Table Declaration
*&---------------------------------------------------------------------*
DATA:BEGIN OF i_tab OCCURS 0,
      kunnr TYPE    rf02d-kunnr,
      ktokd  TYPE     rf02d-ktokd,
      anred TYPE    kna1-anred,
      name1 TYPE    kna1-name1,
      sortl TYPE    kna1-sortl,
      pfach TYPE    kna1-pfach,
      ort01 TYPE    kna1-ort01,
      pstlz TYPE    kna1-pstlz,
      pstl2 TYPE    kna1-pstl2,
      land1 TYPE    kna1-land1,
      spras TYPE    kna1-spras,
      lzone TYPE    kna1-lzone,
 END OF i_tab.
*----------------------------------------------------------------------*
* Selection Screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text_001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) text_1_1.
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
*----------------------------------------------------------------------*
* Initialization Event
*----------------------------------------------------------------------*
INITIALIZATION.
  text_001 = 'File path selection'.
  text_1_1 = 'File Path'.
*----------------------------------------------------------------------*
* At Selection Screen Event
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION 'F4_FILENAME'
    IMPORTING
      file_name = p_file.
*&---------------------------------------------------------------------*
*& Start of Selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM data_upload.
  IF i_tab[] IS NOT INITIAL.
    PERFORM open_group.
    LOOP AT i_tab.
      REFRESH bdcdata.
      PERFORM bdcdata.
    ENDLOOP.
    PERFORM close_group.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  DATA_UPLOAD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM data_upload.
  DATA: loc_filename TYPE string.
  loc_filename = p_file.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = loc_filename
      filetype                = 'DAT'
      has_field_separator     = 'X'
    TABLES
      data_tab                = i_tab
    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.                    " DATA_UPLOAD

*----------------------------------------------------------------------*
*        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                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
  CLEAR bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  APPEND bdcdata.
ENDFORM.                    "BDC_FIELD

*&---------------------------------------------------------------------*
*&      Form  OPEN_GROUP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM open_group .
  CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
      client = sy-mandt
      group  = 'ZRHAN_XD01' "'Session_Name'
      user   = sy-uname
      keep   = 'X'.
ENDFORM.                    " OPEN_GROUP

*&---------------------------------------------------------------------*
*&      Form  CLOSE_GROUP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM close_group .
  CALL FUNCTION 'BDC_CLOSE_GROUP'.
  CALL TRANSACTION 'SM35'.
ENDFORM.                    " CLOSE_GROUP

*&---------------------------------------------------------------------*
*&      Form  bdcdata
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM bdcdata .
*---->>> Insert Recording Here
  PERFORM bdc_dynpro      USING 'SAPMF02D'    '0100'.
  PERFORM bdc_field       USING 'BDC_CURSOR'  'RF02D-KTOKD'.
  PERFORM bdc_field       USING 'BDC_OKCODE'  '/00'.
  PERFORM bdc_field       USING 'RF02D-KUNNR'   i_tab-kunnr. "  'A-5005'.
  PERFORM bdc_field       USING 'RF02D-KTOKD'   i_tab-ktokd."'0001'.
  PERFORM bdc_dynpro      USING 'SAPMF02D'    '0110'.
  PERFORM bdc_field       USING 'BDC_CURSOR'  'KNA1-PSTL2'.
  PERFORM bdc_field       USING 'BDC_OKCODE'  '/00'.
  PERFORM bdc_field       USING 'KNA1-ANRED'    i_tab-anred."'" 'mr'.
  PERFORM bdc_field       USING 'KNA1-NAME1'    i_tab-name1."'avin'.
  PERFORM bdc_field       USING 'KNA1-SORTL'    i_tab-sortl."  'AVIN'.
  PERFORM bdc_field       USING 'KNA1-PFACH'    i_tab-pfach." 'rajapur'.
  PERFORM bdc_field       USING 'KNA1-ORT01'    i_tab-ort01."'RAJAPUR'.
  PERFORM bdc_field       USING 'KNA1-PSTLZ'    i_tab-pstlz." '210207'.
  PERFORM bdc_field       USING 'KNA1-PSTL2'    i_tab-pstl2." '210207'.
  PERFORM bdc_field       USING 'KNA1-LAND1'    i_tab-land1." 'IN'.
  PERFORM bdc_field       USING 'KNA1-SPRAS'    i_tab-spras." 'EN'.
  PERFORM bdc_dynpro      USING 'SAPMF02D'    '0120'.
  PERFORM bdc_field       USING 'BDC_CURSOR'  'KNA1-LZONE'.
  PERFORM bdc_field       USING 'BDC_OKCODE'   '=UPDA'.
  PERFORM bdc_field       USING 'KNA1-LZONE'   i_tab-lzone." '0000000001'.

  PERFORM bdc_insert.
ENDFORM.                    " bdcdata

*&---------------------------------------------------------------------*
*&      Form  bdc_insert
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM bdc_insert.
  CALL FUNCTION 'BDC_INSERT'
    EXPORTING
      tcode     = 'XD01' "'TCODE'
    TABLES
      dynprotab = bdcdata.
ENDFORM.                    " bdc_insert



File Format:

A-50051 0001 Mr lokesh kumar avi raja RAJA    210207 210207 IN EN 0000000001
A-50052 0001 MS POOJA  SING avi raja RAJA 210207 210207 IN EN 0000000001

Most beautiful visiting place in Kolkata


List of most beautiful visiting place in Kolkata.



Kolkata is capital of West Bengal. Kolkata Nicknamed CITY OF JOY.This is very beautiful city in india. If you want to go KOLKATA there is certain place you must see this place.
1. Esplanade.
2. Victoria Memorial Hall Kolkata India.
3. Howrah Bridge.
4.Howrah Station.
5. Kumortuli.
6. Khalighat Temple.
7. Colonial Architecture & City Tours.
8. College Street (Book Market) / Indian Coffee House.
9. Sealdah Station.
10. Indian Museum.
11. New Market.
12. Day Trip to Sundarbans.
13. Durga Puja Festival.
14. Dakshineswar Kali Temple.
15. Belur Math Kolkata.
16.Science City Kolkata.
17.New Town Eco Park.
18.Maidan kolkata.
19.Eden Gardens.
20.Prinsep Ghat kolkata.

Most beautiful visiting place in Paschim / Purbo Medinipur.


List of most beautiful visiting place in Paschim / Purbo Medinipur.
Medinipur is one of  historical place in West bengal. Before 2002 Medinipur is only one district but January 2002 Medinipur Divided 2 district 1. Purbo Medinipur 2.Paschim Medinipur.





Medinipur is the headquarters of the Paschim Medinipur district. Tamluk is the headquarters of the Purbo Medinipur district. Distance Kolkata to Medinipur 77 Km to 133 km.
  • Historical Places
1.     » Bahiri
2.     » Chandrakona
3.     » Dantan
4.     » Egra
5.     » Garbeta
6.     » Gopiballavpur
7.     » Keshiari
8.     » Keshpur
9.     » Moyna
10. » Narayangard
11. » Nayagram
12. » Pathra
13. » Sutahata
  • Costal
1.     » Junput
2.     » Mandarmani
3.     » Sankarpur
4.     » Digha
5.     » Khejuri
  • Forest & Hill
1.     » Jhargram
2.     » Binpur
  • Rivers 
1.     » Kangsabati
2.     » Subarnarekha
3.     » Silaboti
4.     » Keleghai
5.     » Haldi
6.     » Rasalpur
7.     » Dulang & Kushmi
8.     » Tarafeni
9.     » Bhairab Banki
10. » Jayponda
11. » Purandar
12. » Hooghly
13. » Darokeshwar
14. » Tarajuli
15. » Donai
16. » Chandia
17. » Champa
18. » Kapaleswari
19. » Kalaichandi
20. » Pichaboni
21. » Parang-Tamal-Kubai
22. » Kana
23. » Rupnarayan