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
*----------------------------------------------------------------------*
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'.
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 f_fill_item_details
*----------------------------------------------------------------------*
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
*----------------------------------------------------------------------*
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 bdc_close_group
*----------------------------------------------------------------------*
form bdc_close_group .
* close batchinput group
IF E_GROUP_OPENED = 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.