*& Report ZMM_ME31L_UPLOAD
*& Developed by : HARI
*& Description : Schedule agreement data uploading
*&---------------------------------------------------------------------
REPORT ZMMA_ME31L_UPLOAD
NO STANDARD PAGE HEADING
LINE-SIZE 255.
*----------------------------------------------------------------------*
* Include for Types, WA, Itab, Constants, Global Variable declarations *
*----------------------------------------------------------------------*
include ZMMA_ME31L_UPLOAD_TOP.
*----------------------------------------------------------------------*
* At Selection-screen event
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f_get_filename USING p_file.
*----------------------------------------------------------------------*
* Start-of-Selection event
*----------------------------------------------------------------------*
START-OF-SELECTION.
* Subroutine to upload the data into Internal table I_Upload.
PERFORM get_data.
i_ctu_params-defsize = 'X'.
i_ctu_params-NOBINPT = ''.
*i_ctu_params-DISMODE = p_mode.
i_ctu_params-UPDMODE = p_upd.
LOOP AT i_upload where lifnr is not initial.
v_index = sy-tabix.
** Create Scheduling Agreement: Initial Screen
perform bdc_dynpro using 'SAPMM06E' '0200'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-LGORT'.
perform bdc_field using 'BDC_OKCODE'
'=KOPF'.
perform bdc_field using 'EKKO-LIFNR'
I_Upload-Lifnr.
perform bdc_field using 'RM06E-EVART'
I_Upload-evart.
perform bdc_field using 'RM06E-VEDAT'
i_upload-vedat.
perform bdc_field using 'EKKO-EKORG'
i_upload-ekorg.
perform bdc_field using 'EKKO-EKGRP'
i_upload-ekgrp.
perform bdc_field using 'RM06E-WERKS'
i_upload-werks.
perform bdc_field using 'RM06E-LGORT'
i_upload-lgort.
* Create Scheduling Agreement: Header Data
perform bdc_dynpro using 'SAPMM06E' '0201'.
perform bdc_field using 'BDC_CURSOR'
'EKKO-KDATE'.
perform bdc_field using 'BDC_OKCODE'
'=AB'.
perform bdc_field using 'EKKO-KDATB'
i_upload-kdatb.
perform bdc_field using 'EKKO-KDATE'
i_upload-kdate.
cnt1 = 0.
j = 0.
i = 1.
DO.
* this loop for item values.
* cnt1 = cnt1 + 1.
* g_count1 = cnt1.
*
*
** filling the item details.
*
*** Begin of New changes
if j EQ 14.
v_ebelp = i - 1.
perform bdc_dynpro using 'SAPMM06E' '0220'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-EBELP'.
perform bdc_field using 'BDC_OKCODE'
* '=P+'.
'/00'.
perform bdc_field using 'RM06E-EBELP'
v_ebelp.
j = 1.
cnt1 = 2.
* cnt1 = cnt1 + 1.
g_count1 = cnt1.
PERFORM f_fill_item_details.
else.
cnt1 = cnt1 + 1.
g_count1 = cnt1.
PERFORM f_fill_item_details.
endif.
* filling the item details.
i = i + 1.
j = j + 1.
*** Ended New changes
cnt2 = 0.
g_count2 = 0.
do.
* this loop for item condition condition values.
cnt2 = cnt2 + 1.
g_count2 = cnt2.
* filling the item conditions per each item value.
PERFORM f_fill_item_condns.
v_index = v_index + 1.
read table i_upload index v_index.
if sy-subrc eq 0.
if not i_upload-ematn is initial.
exit.
endif.
else.
exit.
endif.
enddo.
perform bdc_dynpro using 'SAPMV13A' '0201'.
perform bdc_field using 'BDC_CURSOR'
'RV13A-DATAB'.
perform bdc_field using 'BDC_OKCODE'
'=BACK '.
* perform bdc_dynpro using 'SAPMM06E' '0211'.
read table i_upload index v_index.
if sy-subrc eq 0.
if not i_upload-lifnr is initial.
exit.
endif.
else.
exit.
endif.
ENDDO.
** confirmation for each new vendor save yes/no.
perform bdc_dynpro using 'SAPMM06E' '0220'.
PERFORM f_get_field USING 'RM06E-EVRTP'
g_count1.
perform bdc_field using 'BDC_CURSOR'
g_field.
perform bdc_field using 'BDC_OKCODE'
* '=BACK'.
'=BU'.
* perform bdc_dynpro using 'SAPLSPO1' '0100'.
* perform bdc_field using 'BDC_OKCODE'
* '=YES'.
PERFORM bdc_transaction using 'ME31L'.
ENDLOOP.
clear i_upload.
refresh i_upload.
free i_upload.
PERFORM bdc_close_group.
*----------------------------------------------------------------------*
* End-of-Selection event
*----------------------------------------------------------------------*
*
END-OF-SELECTION.
SKIP 2.
write:/ 'Total Number of Transactions : ' color 6, g_tot.
SKIP 1.
write:/ 'Total Number of Success Transactions : ' color 5, g_success.
SKIP 1.
write:/ 'Total Number of Error Transactions : ' color 1, g_error.
SKIP 1.
if g_error <> 0.
format color 3.
write:/ 'Please go to Transaction SM35 to process the errors' hotspot.
endif.
*----------------------------------------------------------------------*
* At line-Selection event
*----------------------------------------------------------------------*
*
AT LINE-SELECTION.
if SY-LISEL = 'Please go to Transaction SM35 to process the errors'.
call transaction 'SM35'.
endif.
*
*----------------------------------------------------------------------*
* 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.
*----------------------------------------------------------------------*
* Start new transaction according to parameters *
*----------------------------------------------------------------------*
form bdc_transaction using tcode.
data: l_mstring(480).
data: l_subrc like sy-subrc.
refresh messtab.
CALL TRANSACTION TCODE USING BDCDATA
* MODE p_mode
* UPDATE p_upd
messages into messtab
OPTIONS FROM i_ctu_params.
** counting for success records.
IF sy-SUBRC <> 0.
g_error = g_error + 1.
IF E_GROUP_OPENED = ' '.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = p_sesion
USER = sy-uname
KEEP = 'X'.
E_GROUP_OPENED = 'X'.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE
TABLES
DYNPROTAB = BDCDATA.
else.
** counting for error records
g_success = g_success + 1.
ENDIF.
g_tot = g_tot + 1.
REFRESH BDCDATA.
*
* l_subrc = sy-subrc.
* write: / 'CALL_TRANSACTION',
* tcode,
* 'returncode:'(i05),
* l_subrc,
* 'RECORD:',
* sy-index.
* loop at messtab.
* select single * from t100 where sprsl = messtab-msgspra
* and arbgb = messtab-msgid
* and msgnr = messtab-msgnr.
* if sy-subrc = 0.
* l_mstring = t100-text.
* if l_mstring cs '&1'.
* replace '&1' with messtab-msgv1 into l_mstring.
* replace '&2' with messtab-msgv2 into l_mstring.
* replace '&3' with messtab-msgv3 into l_mstring.
* replace '&4' with messtab-msgv4 into l_mstring.
* else.
* replace '&' with messtab-msgv1 into l_mstring.
* replace '&' with messtab-msgv2 into l_mstring.
* replace '&' with messtab-msgv3 into l_mstring.
* replace '&' with messtab-msgv4 into l_mstring.
* endif.
* condense l_mstring.
* write: / messtab-msgtyp, l_mstring(250).
* else.
* write: / messtab.
* endif.
* endloop.
* skip.
* refresh bdcdata.
endform.
*&---------------------------------------------------------------------*
*& Form Get_data
* write the code to upload the file data in internal table I_UPLOAD.
*----------------------------------------------------------------------*
form get_data .
clear i_upload.
refresh i_upload.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = p_file
FILETYPE = 'DAT'
TABLES
data_tab = i_upload
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 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.
endform. " Get_data
*&---------------------------------------------------------------------*
*& Form f_fill_item_details
*----------------------------------------------------------------------*
form f_fill_item_details.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = g_count1
IMPORTING
output = g_count1.
** Create Scheduling Agreement: Item overview
perform bdc_dynpro using 'SAPMM06E' '0220'.
PERFORM f_get_field USING 'EKPO-KTMNG'
g_count1.
perform bdc_field using 'BDC_CURSOR'
g_field.
perform bdc_field using 'BDC_OKCODE'
* '=DETZ'.
'/00'.
* PERFORM f_get_field USING 'RM06E-TCSELFLAG'
* g_count1.
* perform bdc_field using g_field
* 'X'.
* Begin of changes on DEVK903540 Request by Hari.
PERFORM f_get_field USING 'EKPO-KNTTP'
g_count1.
perform bdc_field using g_field
i_upload-knttp.
* End of changes on DEVK903540 Request by Hari.
PERFORM f_get_field USING 'EKPO-EMATN'
g_count1.
perform bdc_field using g_field
i_upload-ematn.
PERFORM f_get_field USING 'EKPO-KTMNG'
g_count1.
perform bdc_field using g_field
i_upload-ktmng.
* PERFORM f_get_field USING 'EKPO-NETPR'
* g_count1.
* perform bdc_field using g_field
* ' 1'.
* Begin of changes on DEVK903540 Request by Hari.
IF i_upload-knttp NE SPACE.
** getting GL A/C Details.
perform bdc_dynpro using 'SAPMM06E' '0511'.
perform bdc_field using 'BDC_CURSOR'
'EKKN-SAKTO'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'EKKN-SAKTO'
i_upload-sakto.
** getting Cost Center value.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-KOSTL'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-KOSTL'
i_upload-kostl.
ENDIF.
** Create Scheduling Agreement: Item detials
perform bdc_dynpro using 'SAPMM06E' '0220'.
PERFORM f_get_field USING 'RM06E-EVRTP'
g_count1.
perform bdc_field using 'BDC_CURSOR'
g_field.
perform bdc_field using 'BDC_OKCODE'
'=DETA'.
* perform bdc_field using 'RM06E-EBELP'
* '1'.
PERFORM f_get_field USING 'RM06E-TCSELFLAG'
g_count1.
perform bdc_field using g_field
'X'.
perform bdc_dynpro using 'SAPMM06E' '0211'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-MWSKZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EKPO-BSTAE'
i_upload-bstae.
perform bdc_field using 'EKPO-MWSKZ'
i_upload-mwskz.
* End of changes on DEVK903540 Request by Hari.
*** Create Scheduling Agreement: Item overview
*
perform bdc_dynpro using 'SAPMM06E' '0220'.
PERFORM f_get_field USING 'RM06E-EVRTP'
g_count1.
perform bdc_field using 'BDC_CURSOR'
g_field.
perform bdc_field using 'BDC_OKCODE'
'=DETZ'.
* perform bdc_field using 'RM06E-EBELP'
* '1'.
PERFORM f_get_field USING 'RM06E-TCSELFLAG'
g_count1.
perform bdc_field using g_field
'X'.
** Create Scheduling Agreement: Additional data
perform bdc_dynpro using 'SAPMM06E' '0212'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-ETFZ2'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EKPO-ETFZ1'
i_upload-etfz1.
perform bdc_field using 'EKPO-ETFZ2'
i_upload-etfz2.
* Begin of Add DEVK903540 Request by Hari.
perform bdc_field using 'EKPO-KZSTU'
i_upload-kzstu.
* End of Add on DEVK903540 Request by Hari.
** Create Scheduling Agreement: Item overview
perform bdc_dynpro using 'SAPMM06E' '0220'.
PERFORM f_get_field USING 'RM06E-EVRTP'
g_count1.
perform bdc_field using 'BDC_CURSOR'
g_field.
perform bdc_field using 'BDC_OKCODE'
'=KO'.
* perform bdc_field using 'RM06E-EBELP'
* '1'.
PERFORM f_get_field USING 'RM06E-TCSELFLAG'
g_count1.
perform bdc_field using g_field
'X'.
perform bdc_dynpro using 'SAPMV13A' '0201'.
PERFORM f_get_field USING 'KONP-KBETR'
g_count1.
perform bdc_field using 'BDC_CURSOR'
g_field.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RV13A-DATAB'
i_upload-datab.
perform bdc_field using 'RV13A-DATBI'
i_upload-datbi.
endform. " f_fill_operation
*&---------------------------------------------------------------------*
*& Form f_get_field
*----------------------------------------------------------------------*
form f_get_field using p_name p_count1 .
CLEAR: g_field.
CONCATENATE p_name '(' p_count1 ')' INTO g_field.
endform. " f_get_field
*&---------------------------------------------------------------------*
*& Form f_fill_item_condns
*----------------------------------------------------------------------*
form f_fill_item_condns .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = g_count2
IMPORTING
output = g_count2.
PERFORM f_get_field2 USING 'KONP-KSCHL'
g_count2.
perform bdc_field using g_field2
i_upload-kschl.
PERFORM f_get_field2 USING 'KONP-KBETR'
g_count2.
perform bdc_field using g_field2
i_upload-kbetr.
* Begin of changes on DEVK903540 Request by Hari.
PERFORM f_get_field2 USING 'KONP-KPEIN'
g_count2.
perform bdc_field using g_field2
i_upload-kpein.
* End of changes on DEVK903540 Request by Hari.
endform. " f_fill_item_condns
*&---------------------------------------------------------------------*
*& Form f_get_field2
*----------------------------------------------------------------------*
form f_get_field2 using p_name2 p_count2.
clear: g_field2.
CONCATENATE p_name2 '(' p_count2 ')' INTO g_field2.
endform. " f_get_field2
*&---------------------------------------------------------------------*
*& Form f_get_filename
*----------------------------------------------------------------------*
form f_get_filename using p_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
* DEF_FILENAME = ' '
* DEF_PATH = ' '
mask = ',*.*,*.*.'
mode = 'O'
title = ' '
IMPORTING
filename = p_file
* RC =
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5 .
endform. " f_get_filename
*&---------------------------------------------------------------------*
*& Form bdc_close_group
*----------------------------------------------------------------------*
form bdc_close_group .
* close batchinput group
IF E_GROUP_OPENED = 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
ENDIF.
endform. " bdc_close_group
Friday, November 23, 2007
Schedule Agreement Data Uploading in sap bdc
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment