0% found this document useful (0 votes)
95 views5 pages

ZBDC VNDR Mas Change

This document provides a summary of a BDC (Batch Data Communication) program called ZBDC_VNDR_MAS_CHANGE that is used to update vendor master data in SAP. The summary includes: 1) The program uploads a file, runs BDC to update vendor fields for each record in the file, and generates a session for transaction XK02. 2) It updates fields like company code, vendor number, region, sales tax code, and vendor class using BDC functions. 3) Any error messages generated are formatted and displayed after processing the file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views5 pages

ZBDC VNDR Mas Change

This document provides a summary of a BDC (Batch Data Communication) program called ZBDC_VNDR_MAS_CHANGE that is used to update vendor master data in SAP. The summary includes: 1) The program uploads a file, runs BDC to update vendor fields for each record in the file, and generates a session for transaction XK02. 2) It updates fields like company code, vendor number, region, sales tax code, and vendor class using BDC functions. 3) Any error messages generated are formatted and displayed after processing the file.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

*&--------------------------------------------------------------------*

*& Report ZBDC_VNDR_MAS_CHANGE


*&--------------------------------------------------------------------*
* Prog Name: ZBDC_VNDR_MAS_CHANGE BDC Creation: 08/06/2017 *
* *
* Prog Name : ZBDC_VNDR_MAS_CHANGE Application: MM *
* *
* Author : Type: 1 *
*_____________________________________________________________________*
* Description: BDC for XK02 *
* *
*_____________________________________________________________________*
* *
* SSCRFIELDS. *
*_____________________________________________________________________*
* External Routines *
* Function Modules: *
* *
* *
* Transactions : ZMM285 *
* Programs : No *
*_____________________________________________________________________*
* Return Codes: No *
*_____________________________________________________________________*
* Amendments: *
* Ver Programmer Date Req. # Action *
* 1. 08/06/2017 ECDK9A0CLW Initial development *
***********************************************************************

REPORT zbdc_vndr_mas_change NO STANDARD PAGE HEADING LINE-SIZE 255.

INCLUDE zbdc_vmasc_top.

**----------------------------------------------------------------**
*** At Selection Screen on Value Request **
**----------------------------------------------------------------**
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f4_p_file.

START-OF-SELECTION.

REFRESH:it_file,
it_messages.

PERFORM upload_file TABLES it_file USING p_file.


IF it_file IS NOT INITIAL.
PERFORM bdc.
ENDIF.
* PERFORM messages.

*&---------------------------------------------------------------------*
*& Form BDC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*

FORM bdc.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = 'VENDORCHANGE'
user = sy-uname
keep = 'X'.

LOOP AT it_file INTO fs_file.


REFRESH bdcdata.
PERFORM bdc_dynpro USING 'SAPMF02K' '0101'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-D0220'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-LIFNR'
fs_file-field1.
PERFORM bdc_field USING 'RF02K-BUKRS'
fs_file-field2.
* PERFORM bdc_field USING 'RF02K-EKORG'
* fs_file-field3.
PERFORM bdc_field USING 'RF02K-D0110'
'X'.
PERFORM bdc_field USING 'RF02K-D0120'
'X'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.


PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-REGIO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-LAND1'
'IN'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = fs_file-field4
IMPORTING
output = fs_file-field4.

PERFORM bdc_field USING 'LFA1-REGIO'


fs_file-field4."'13'.

PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.


PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-STCD3'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=OPFI'.
PERFORM bdc_field USING 'LFA1-STCD3'
fs_file-field5."'G33100111'.

PERFORM bdc_dynpro USING 'SAPLJ1I_MASTER' '0100'.


PERFORM bdc_field USING 'BDC_OKCODE'
'=CIN_VENDOR_FC5'.
PERFORM bdc_field USING 'BDC_CURSOR'
'J_1IMOVEND-J_1IEXCD'.
PERFORM bdc_dynpro USING 'SAPLJ1I_MASTER' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'J_1IMOVEND-VEN_CLASS'.
PERFORM bdc_field USING 'J_1IMOVEND-VEN_CLASS'
fs_file-field6."'0'.

PERFORM bdc_dynpro USING 'SAPLJ1I_MASTER' '0100'.


PERFORM bdc_field USING 'BDC_OKCODE'
'=BACK'.
PERFORM bdc_field USING 'BDC_CURSOR'
'J_1IMOVEND-VEN_CLASS'.
PERFORM bdc_field USING 'J_1IMOVEND-VEN_CLASS'
fs_file-field6."'0'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPDA'.
PERFORM bdc_field USING 'LFA1-STCD3'
fs_file-field5."'G33100111'.

* PERFORM bdc_transaction.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'XK02'
TABLES
dynprotab = bdcdata.
CLEAR fs_file.
ENDLOOP.

CALL FUNCTION 'BDC_CLOSE_GROUP'.


MESSAGE i001(38) WITH 'Session Generated'.
CALL TRANSACTION 'SM35'.

ENDFORM. " BDC

*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM.

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM.

*&---------------------------------------------------------------------*
*& Form F4_P_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_p_file .

CALL FUNCTION 'F4_FILENAME'


EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.

IF sy-subrc <> 0 AND sy-subrc <> 3.


MESSAGE 'Error Selecting File' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.

ENDFORM. " F4_P_FILE


*&---------------------------------------------------------------------*
*& Form UPLOAD_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_FILE text
* -->P_P_FILE text
*----------------------------------------------------------------------*
FORM upload_file TABLES it_file
USING p_file.
DATA: file_name TYPE rlgrap-filename.
DATA : it_type TYPE truxs_t_text_data.

file_name = p_file.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'


EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = it_type
i_filename = file_name
TABLES
i_tab_converted_data = it_file[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.

IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

ENDFORM. " UPLOAD_FILE

" FINAL_DATA
*&---------------------------------------------------------------------*
*& Form MESSAGES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM messages.

LOOP AT it_messages INTO fs_messages.


CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
lang = '-D'
no = fs_messages-msgnr
v1 = fs_messages-msgv1
v2 = fs_messages-msgv2
v3 = fs_messages-msgv3
v4 = fs_messages-msgv4
IMPORTING
msg = lv_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF fs_messages-msgtyp = 'E'.
WRITE /: lv_msg.
ELSEIF fs_messages-msgtyp = 'S'.
WRITE /: lv_msg.
ENDIF.
CLEAR fs_messages.
ENDLOOP.
ENDFORM. " MESSAGES

*&---------------------------------------------------------------------*
*& Form BDC_TRANSACTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM bdc_transaction.
CALL TRANSACTION 'XK02' USING bdcdata OPTIONS FROM batch_params MESSAGES INTO it_messages.
REFRESH bdcdata.
CLEAR bdcdata.
ENDFORM. " BDC_TRANSACTION

You might also like