Hi ALL i have a BDC code  it is not working properly

this BDC code is not working properly , when ever the file is transfering BDC is aborting in the case of   invalid material/batch comes into teh picture... so please could you ''Check for invalid material/batch combinations so they are not processed by the BDC in the program and correctly output in an exception report''
*****************************CODE HERE*****************************
S E L E C T I O N S C R E E N
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_file LIKE rlgrap-filename,
p_arch LIKE rlgrap-filename. "RM080107
SELECTION-SCREEN SKIP.
PARAMETERS: p_mode LIKE ctu_params-dismode DEFAULT 'N'.
SELECTION-SCREEN END OF BLOCK b1.
I N C L U D E S
INCLUDE zwm_np_stock_recon_top.
INCLUDE zwm_np_stock_recon_f01.
I N I T I A L I Z A T I O N
INITIALIZATION.
PERFORM get_interface_filename USING c_interface_file p_file.
PERFORM get_interface_filename USING c_archive_file p_arch."RM080107
S T A R T O F S E L E C T I O N
START-OF-SELECTION.
PERFORM read_file USING p_file.
PERFORM pre_processing.
E N D O F S E L E C T I O N
END-OF-SELECTION.
PERFORM process_checks.
IF w_no_change = 'X'.
WRITE: / text-b03.
WRITE: / sy-uline(34).
ELSE.
PERFORM bdc_mi09.
PERFORM file_check_report.
PERFORM bdc_report.
ENDIF.
PERFORM post_process_checks.
*-- Move the processed file to archive directory
PERFORM move_file.
...*************.........first include...................************
INCLUDE ZWM_NP_STOCK_RECON_TOP *
Data declaration ----------------------------------------------
TYPES: st_rawdata(2000) TYPE c.
TYPES: BEGIN OF st_stck_cnt,
werks TYPE iseg-werks, "plant
lgort TYPE iseg-lgort, "storage location
matnr TYPE iseg-matnr, "material number
charg TYPE iseg-charg, "batch
vfdat TYPE mch1-vfdat, "Sell by date
lwedt TYPE mch1-lwedt, "Manufacture date
quarn(8) TYPE n, "qaunrantine quantity
menge(8) TYPE n, "quantity on hand
message(1), "Message Type (E/W/I)
msg_txt TYPE t100-text, "Message Text
zerostck(1), "Zero stock identifier "RM220307
END OF st_stck_cnt.
TYPES: BEGIN OF st_batch_errors,
matnr TYPE iseg-matnr, "material number
charg TYPE iseg-charg, "batch
clabs TYPE mchb-clabs, "Stock Balance
END OF st_batch_errors.
DATA:
t_rawdata TYPE TABLE OF st_rawdata,
w_rawdata TYPE st_rawdata,
t_stck_cnt TYPE TABLE OF st_stck_cnt,
d_stck_cnt TYPE TABLE OF st_stck_cnt, "RM191006
w_stck_cnt TYPE st_stck_cnt,
t_batch_errors TYPE TABLE OF st_batch_errors,
w_batch_errors TYPE st_batch_errors,
t_messtab LIKE bdcmsgcoll OCCURS 0,
w_messtab LIKE LINE OF t_messtab,
w_no_change.
CONSTANTS: c_interface_file(26) TYPE c VALUE 'ZNP_STOCK_RECON',
c_archive_file(26) TYPE c
VALUE 'ZNP_STOCK_RECON_ARCHIVE'. "RM080107
.*************................second include..........************
***INCLUDE ZWM_NEXTPHARMA_STOKRECON_F01 .
*& Form read_file
reads NextPharma file sent through via webmethods
-->P_FILENAME
FORM read_file USING p_filename.
CLEAR: t_rawdata,
w_rawdata.
REFRESH: t_rawdata.
OPEN DATASET p_filename FOR INPUT IN TEXT MODE.
IF sy-subrc <> 0.
MESSAGE e720(01).
ENDIF.
DO.
READ DATASET p_filename INTO w_rawdata.
IF sy-subrc <> 0.
EXIT.
ELSE.
APPEND w_rawdata TO t_rawdata.
ENDIF.
ENDDO.
CLOSE DATASET p_filename.
ENDFORM. " read_file
*& Form pre_processing
Read file values into internal table
FORM pre_processing.
DATA: lw_matnr TYPE iseg-matnr.
LOOP AT t_rawdata INTO w_rawdata.
lw_matnr = w_rawdata+21(20). "RM031006
lw_matnr = w_rawdata+22(18). "RM031006
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = lw_matnr
IMPORTING
output = lw_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
MOVE: lw_matnr TO w_stck_cnt-matnr.
w_stck_cnt-werks = w_rawdata+14(4).
w_stck_cnt-lgort = w_rawdata+18(4).
w_stck_cnt-charg = w_rawdata+84(25).
w_stck_cnt-vfdat = w_rawdata+109(8).
w_stck_cnt-lwedt = w_rawdata+117(8).
w_stck_cnt-quarn = w_rawdata+141(8).
w_stck_cnt-menge = w_rawdata+125(8).
APPEND w_stck_cnt TO t_stck_cnt.
CLEAR w_stck_cnt.
ENDLOOP.
SORT t_stck_cnt BY werks
lgort
matnr
charg.
DELETE ADJACENT DUPLICATES FROM t_stck_cnt.
ENDFORM. " pre_processing
*& Form bdc_mi09
Run file data via BDC TCODE: MI09
FORM bdc_mi09.
DATA: t_bdcdata TYPE TABLE OF bdcdata,
w_bdcdata TYPE bdcdata,
lw_datum(10) TYPE c,
lw_count(2) TYPE n.
WRITE sy-datum TO lw_datum DD/MM/YYYY.
Front Screen
CLEAR w_bdcdata.
w_bdcdata-program = 'SAPMM07I'.
w_bdcdata-dynpro = '0700'.
w_bdcdata-dynbegin = 'X'.
APPEND w_bdcdata TO t_bdcdata.
Enter
CLEAR w_bdcdata.
w_bdcdata-fnam = 'BDC_OKCODE'.
w_bdcdata-fval = '/00'.
APPEND w_bdcdata TO t_bdcdata.
Count Date
CLEAR w_bdcdata.
w_bdcdata-fnam = 'RM07I-ZLDAT'.
w_bdcdata-fval = lw_datum.
APPEND w_bdcdata TO t_bdcdata.
Document Date
CLEAR w_bdcdata.
w_bdcdata-fnam = 'RM07I-BLDAT'.
w_bdcdata-fval = lw_datum.
APPEND w_bdcdata TO t_bdcdata.
Plant
CLEAR w_bdcdata.
w_bdcdata-fnam = 'IKPF-WERKS'.
w_bdcdata-fval = w_stck_cnt-werks.
APPEND w_bdcdata TO t_bdcdata.
Storage Location
CLEAR w_bdcdata.
w_bdcdata-fnam = 'IKPF-LGORT'.
w_bdcdata-fval = w_stck_cnt-lgort.
APPEND w_bdcdata TO t_bdcdata.
LOOP AT t_stck_cnt INTO w_stck_cnt.
Do not submit items with Errors against them
CHECK w_stck_cnt-message NE 'E' AND
w_stck_cnt-zerostck NE 'X'.
"RM220307
lw_count = lw_count + 1.
Input Screen
CLEAR w_bdcdata.
w_bdcdata-program = 'SAPMM07I'.
w_bdcdata-dynpro = '0731'.
w_bdcdata-dynbegin = 'X'.
APPEND w_bdcdata TO t_bdcdata.
Page Down
CLEAR w_bdcdata.
w_bdcdata-fnam = 'BDC_OKCODE'.
w_bdcdata-fval = '=P+'.
APPEND w_bdcdata TO t_bdcdata.
Material
CLEAR w_bdcdata.
w_bdcdata-fnam = 'ISEG-MATNR(01)'.
w_bdcdata-fval = w_stck_cnt-matnr.
APPEND w_bdcdata TO t_bdcdata.
Batch
CLEAR w_bdcdata.
w_bdcdata-fnam = 'ISEG-CHARG(01)'.
w_bdcdata-fval = w_stck_cnt-charg.
APPEND w_bdcdata TO t_bdcdata.
IF w_stck_cnt-menge NE 0.
Quantity
CLEAR w_bdcdata.
w_bdcdata-fnam = 'ISEG-ERFMG(01)'.
w_bdcdata-fval = w_stck_cnt-menge.
APPEND w_bdcdata TO t_bdcdata.
*-- Begin RM220307 - We need to create an item when the quantity is zero
*-- in file and is non-zero in SAP
ELSE.
Zero Stock indicator
CLEAR w_bdcdata.
w_bdcdata-fnam = 'ISEG-XNULL(01)'.
w_bdcdata-fval = 'X'.
APPEND w_bdcdata TO t_bdcdata.
*-- End RM220307
ENDIF.
ENDLOOP.
CHECK lw_count NE 0.
After all line items have been input
Final Screen
CLEAR w_bdcdata.
w_bdcdata-program = 'SAPMM07I'.
w_bdcdata-dynpro = '0731'.
w_bdcdata-dynbegin = 'X'.
APPEND w_bdcdata TO t_bdcdata.
Save Document
CLEAR w_bdcdata.
w_bdcdata-fnam = 'BDC_OKCODE'.
w_bdcdata-fval = '=BU'.
APPEND w_bdcdata TO t_bdcdata.
CALL TRANSACTION 'MI09' USING t_bdcdata
MODE p_mode
MESSAGES INTO t_messtab.
ENDFORM. " bdc_mi09
*& Form bdc_report
Write BDC Messages.
FORM bdc_report.
DATA: lw_text TYPE t100-text.
SKIP.
WRITE: / text-b01.
WRITE: / sy-uline(21).
SKIP.
Write BDC Messages
LOOP AT t_messtab INTO w_messtab WHERE msgspra = sy-langu.
MESSAGE ID w_messtab-msgid TYPE w_messtab-msgtyp
NUMBER w_messtab-msgnr
WITH w_messtab-msgv1
w_messtab-msgv2
w_messtab-msgv3
w_messtab-msgv4
INTO lw_text.
WRITE: / lw_text.
ENDLOOP.
ENDFORM. " bdc_report
*& Form process_checks
Perform process check before creating BDC Session
FORM process_checks.
DATA: lw_clabs LIKE mchb-clabs,
lw_menge LIKE mchb-clabs,
lw_matnr LIKE mara-matnr,
lw_charg LIKE mch1-charg,
lw_fail,
lw_vfdat TYPE mch1-vfdat,
lv_sell TYPE c, "RM191006
lv_qty(8) TYPE c. "RM191006
CLEAR: d_stck_cnt[], d_stck_cnt. "RM191006
Check if any of the stock figures differ from current stock figures
LOOP AT t_stck_cnt INTO w_stck_cnt.
lw_menge = w_stck_cnt-menge.
SELECT SINGLE clabs INTO lw_clabs
FROM mchb
WHERE matnr = w_stck_cnt-matnr
AND werks = w_stck_cnt-werks
AND lgort = w_stck_cnt-lgort
AND charg = w_stck_cnt-charg.
IF sy-subrc = 0.
IF lw_clabs NE lw_menge.
lw_fail = 'X'.
*-- Begin RM220307 - Do not create PI item if the stock is zero in the
*-- file and is zero in SAP
EXIT.
ELSEIF lw_clabs = 0 AND lw_menge = 0.
w_stck_cnt-zerostck = 'X'.
MODIFY t_stck_cnt FROM w_stck_cnt.
ENDIF.
*-- End RM220307
ELSE.
lw_fail = 'X'.
ERROR
ENDIF.
ENDLOOP.
If no differences are found set NO CHANGE Flag
IF lw_fail NE 'X'.
w_no_change = 'X'.
EXIT.
ENDIF.
Check for Errors in file data
LOOP AT t_stck_cnt INTO w_stck_cnt.
CLEAR lv_sell. "RM191006
SELECT SINGLE matnr INTO lw_matnr
FROM mara
WHERE matnr = w_stck_cnt-matnr.
IF sy-subrc NE 0.
Invalid Material (E)
w_stck_cnt-message = 'E'.
w_stck_cnt-msg_txt = 'Invalid Material'.
MODIFY t_stck_cnt FROM w_stck_cnt.
CONTINUE.
ENDIF.
SELECT SINGLE charg vfdat
INTO (lw_charg, lw_vfdat)
FROM mch1 "KOB01 - changed from MCHA
WHERE matnr = w_stck_cnt-matnr
AND charg = w_stck_cnt-charg.
AND werks = w_stck_cnt-werks.
IF sy-subrc NE 0.
Invalid Material Batch (E)
w_stck_cnt-message = 'E'.
CONCATENATE 'Invalid Material Batch for plant' w_stck_cnt-werks
INTO w_stck_cnt-msg_txt SEPARATED BY space.
MODIFY t_stck_cnt FROM w_stck_cnt.
CONTINUE.
ELSE.
IF w_stck_cnt-vfdat <> lw_vfdat.
Sell by dates do not match (W)
w_stck_cnt-message = 'W'.
w_stck_cnt-msg_txt =
'Sell by Date does not match Shelf life Expiry Date'.
MODIFY t_stck_cnt FROM w_stck_cnt.
lv_sell = 'X'. "RM191006
CONTINUE. "RM191006
ENDIF.
ENDIF.
IF w_stck_cnt-quarn > 0.
Quarantine balance not Zero (W)
w_stck_cnt-message = 'W'.
*-- Begin RM191006
*-- We do want all warning messages on the report
lv_qty = w_stck_cnt-quarn.
CONDENSE lv_qty NO-GAPS.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = lv_qty
IMPORTING
output = lv_qty.
w_stck_cnt-msg_txt = 'Quarantine balance is not zero'.
CONCATENATE 'Quarantine balance is ' lv_qty '- not zero'
INTO w_stck_cnt-msg_txt SEPARATED BY space.
MODIFY t_stck_cnt FROM w_stck_cnt.
CONTINUE.
IF lv_sell = 'X'.
APPEND w_stck_cnt TO d_stck_cnt.
CLEAR lv_sell.
ELSE.
MODIFY t_stck_cnt FROM w_stck_cnt.
ENDIF.
*-- End RM191006
ENDIF.
ENDLOOP.
*-- Begin RM191006
*-- Finally get all the records into dummy table to report
APPEND LINES OF t_stck_cnt TO d_stck_cnt.
SORT d_stck_cnt.
DELETE ADJACENT DUPLICATES FROM d_stck_cnt.
*-- End RM191006
ENDFORM. " process_checks
*& Form file_check_report
Write warning and Error messages from File checks
FORM file_check_report.
WRITE: /2 'Material',
22 'Batch',
32 'Sell By',
45 'Message Text'.
WRITE: /2 sy-uline(115).
SKIP.
LOOP AT t_stck_cnt INTO w_stck_cnt. "RM191006
LOOP AT d_stck_cnt INTO w_stck_cnt. "RM191006
CHECK w_stck_cnt-message NE ' '.
WRITE: /2 w_stck_cnt-matnr,
22 w_stck_cnt-charg,
32 w_stck_cnt-vfdat,
43 w_stck_cnt-message,
45 w_stck_cnt-msg_txt.
ENDLOOP.
ENDFORM. " file_check_report
*& Form post_process_checks
Check Material Batches in SAP against NP File
FORM post_process_checks.
RANGES: r_matnr FOR mchb-matnr,
r_lgort FOR mchb-lgort,
r_werks FOR mchb-werks.
SORT t_stck_cnt.
LOOP AT t_stck_cnt INTO w_stck_cnt.
AT END OF matnr.
r_lgort-sign = 'I'.
r_lgort-option = 'EQ'.
r_lgort-low = w_stck_cnt-lgort.
APPEND r_lgort.
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-low = w_stck_cnt-werks.
APPEND r_werks.
r_matnr-sign = 'I'.
r_matnr-option = 'EQ'.
r_matnr-low = w_stck_cnt-matnr.
APPEND r_matnr.
ENDAT.
ENDLOOP.
Select all material batches for NP Materials
SELECT matnr charg clabs
INTO TABLE t_batch_errors
FROM mchb
WHERE werks IN r_werks
AND lgort IN r_lgort.
IF sy-subrc EQ 0.
Check if the Material Batches are in the NP file
LOOP AT t_batch_errors INTO w_batch_errors.
Disregard Batches without positive unrestricted stock
IF w_batch_errors-clabs LE 0.
DELETE t_batch_errors.
CONTINUE.
ENDIF.
READ TABLE t_stck_cnt INTO w_stck_cnt
WITH KEY matnr = w_batch_errors-matnr
charg = w_batch_errors-charg.
IF sy-subrc = 0.
DELETE t_batch_errors.
ENDIF.
ENDLOOP.
ENDIF.
CHECK NOT t_batch_errors[] IS INITIAL.
Write Batch chak results to report
SKIP.
WRITE: / text-b02.
WRITE: / sy-uline(74).
WRITE: /2 'Material',
22 'Batch'.
WRITE: /2 sy-uline(32).
SKIP.
LOOP AT t_batch_errors INTO w_batch_errors.
WRITE: /2 w_batch_errors-matnr,
22 w_batch_errors-charg.
ENDLOOP.
ENDFORM. " post_process_checks
G E T _ I N T E R F A C E _ F I L E N A M E
FORM get_interface_filename USING filename lw_path.
DATA: i_file TYPE filename-fileintern,
out_filename LIKE v_path-pathextern.
CLEAR: out_filename.
i_file = filename.
get the interface filename to be used when creating file
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
logical_filename = i_file
IMPORTING
file_name = out_filename
EXCEPTIONS
file_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
MOVE out_filename TO lw_path.
IF filename NE c_archive_file. "RM080107
CONCATENATE lw_path 'NP_StockBalance.dat'
INTO lw_path.
*-- Begin RM080107 - Add timestamp to the archived file
ELSE.
CONCATENATE lw_path 'NP_StockBalance' sy-datum sy-uzeit '.dat'
INTO lw_path.
ENDIF.
*-- End RM080107
ELSE.
ENDIF.
ENDFORM. "get_interface_filename
*& Form move_file RM080107
Move the processed file to archive directory
FORM move_file.
*-- At last move the file to archive directory
OPEN DATASET p_arch FOR OUTPUT IN TEXT MODE.
IF sy-subrc = 0.
LOOP AT t_rawdata INTO w_rawdata.
TRANSFER w_rawdata TO p_arch.
ENDLOOP.
ENDIF.
CLOSE DATASET p_arch.
DELETE DATASET p_file.
ENDFORM. " move_file

Hi,
S E L E C T I O N S C R E E N
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_file LIKE rlgrap-filename,
p_arch LIKE rlgrap-filename. "RM080107
SELECTION-SCREEN SKIP.
PARAMETERS: p_mode LIKE ctu_params-dismode DEFAULT 'N'.
SELECTION-SCREEN END OF BLOCK b1.
I N C L U D E S
INCLUDE zwm_np_stock_recon_top.
INCLUDE zwm_np_stock_recon_f01.
I N I T I A L I Z A T I O N
INITIALIZATION.
PERFORM get_interface_filename USING c_interface_file p_file.
PERFORM get_interface_filename USING c_archive_file p_arch."RM080107
S T A R T O F S E L E C T I O N
START-OF-SELECTION.
PERFORM read_file USING p_file.
PERFORM pre_processing.
E N D O F S E L E C T I O N
END-OF-SELECTION.
PERFORM process_checks.
IF w_no_change = 'X'.
WRITE: / text-b03.
WRITE: / sy-uline(34).
ELSE.
PERFORM bdc_mi09.
PERFORM file_check_report.
PERFORM bdc_report.
ENDIF.
PERFORM post_process_checks.
*-- Move the processed file to archive directory
PERFORM move_file.
...*************.........first include...................************
INCLUDE ZWM_NP_STOCK_RECON_TOP *
Data declaration ----------------------------------------------
TYPES: st_rawdata(2000) TYPE c.
TYPES: BEGIN OF st_stck_cnt,
werks TYPE iseg-werks, "plant
lgort TYPE iseg-lgort, "storage location
matnr TYPE iseg-matnr, "material number
charg TYPE iseg-charg, "batch
vfdat TYPE mch1-vfdat, "Sell by date
lwedt TYPE mch1-lwedt, "Manufacture date
quarn(8) TYPE n, "qaunrantine quantity
menge(8) TYPE n, "quantity on hand
message(1), "Message Type (E/W/I)
msg_txt TYPE t100-text, "Message Text
zerostck(1), "Zero stock identifier "RM220307
END OF st_stck_cnt.
TYPES: BEGIN OF st_batch_errors,
matnr TYPE iseg-matnr, "material number
charg TYPE iseg-charg, "batch
clabs TYPE mchb-clabs, "Stock Balance
END OF st_batch_errors.
DATA:
t_rawdata TYPE TABLE OF st_rawdata,
w_rawdata TYPE st_rawdata,
t_stck_cnt TYPE TABLE OF st_stck_cnt,
d_stck_cnt TYPE TABLE OF st_stck_cnt, "RM191006
w_stck_cnt TYPE st_stck_cnt,
t_batch_errors TYPE TABLE OF st_batch_errors,
w_batch_errors TYPE st_batch_errors,
t_messtab LIKE bdcmsgcoll OCCURS 0,
w_messtab LIKE LINE OF t_messtab,
w_no_change.
CONSTANTS: c_interface_file(26) TYPE c VALUE 'ZNP_STOCK_RECON',
c_archive_file(26) TYPE c
VALUE 'ZNP_STOCK_RECON_ARCHIVE'. "RM080107
.*************................second include..........************
***INCLUDE ZWM_NEXTPHARMA_STOKRECON_F01 .
*& Form read_file
reads NextPharma file sent through via webmethods
-->P_FILENAME
FORM read_file USING p_filename.
CLEAR: t_rawdata,
w_rawdata.
REFRESH: t_rawdata.
OPEN DATASET p_filename FOR INPUT IN TEXT MODE.
IF sy-subrc <> 0.
MESSAGE e720(01).
ENDIF.
DO.
READ DATASET p_filename INTO w_rawdata.
IF sy-subrc <> 0.
EXIT.
ELSE.
APPEND w_rawdata TO t_rawdata.
ENDIF.
ENDDO.
CLOSE DATASET p_filename.
ENDFORM. " read_file
*& Form pre_processing
Read file values into internal table
FORM pre_processing.
DATA: lw_matnr TYPE iseg-matnr.
LOOP AT t_rawdata INTO w_rawdata.
lw_matnr = w_rawdata+21(20). "RM031006
lw_matnr = w_rawdata+22(18). "RM031006
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = lw_matnr
IMPORTING
output = lw_matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
MOVE: lw_matnr TO w_stck_cnt-matnr.
w_stck_cnt-werks = w_rawdata+14(4).
w_stck_cnt-lgort = w_rawdata+18(4).
w_stck_cnt-charg = w_rawdata+84(25).
w_stck_cnt-vfdat = w_rawdata+109(8).
w_stck_cnt-lwedt = w_rawdata+117(8).
w_stck_cnt-quarn = w_rawdata+141(8).
w_stck_cnt-menge = w_rawdata+125(8).
APPEND w_stck_cnt TO t_stck_cnt.
CLEAR w_stck_cnt.
ENDLOOP.
SORT t_stck_cnt BY werks
lgort
matnr
charg.
DELETE ADJACENT DUPLICATES FROM t_stck_cnt.
ENDFORM. " pre_processing
*& Form bdc_mi09
Run file data via BDC TCODE: MI09
FORM bdc_mi09.
DATA: t_bdcdata TYPE TABLE OF bdcdata,
w_bdcdata TYPE bdcdata,
lw_datum(10) TYPE c,
lw_count(2) TYPE n.
WRITE sy-datum TO lw_datum DD/MM/YYYY.
<b>select single MATNR
                   WERKS
                   CHARG
           from MCHA
           into (l_matnr, l_werks, l_charg)
           where matnr = w_stck_cnt-matnr
              and werks = w_stck_cnt-werks.
              and charg =  w_stck_cnt-charg.
if sy-subrc ne 0.
continue.
endif.</b>
Front Screen
CLEAR w_bdcdata.
w_bdcdata-program = 'SAPMM07I'.
w_bdcdata-dynpro = '0700'.
w_bdcdata-dynbegin = 'X'.
APPEND w_bdcdata TO t_bdcdata.
Enter
CLEAR w_bdcdata.
w_bdcdata-fnam = 'BDC_OKCODE'.
w_bdcdata-fval = '/00'.
APPEND w_bdcdata TO t_bdcdata.
Count Date
CLEAR w_bdcdata.
w_bdcdata-fnam = 'RM07I-ZLDAT'.
w_bdcdata-fval = lw_datum.
APPEND w_bdcdata TO t_bdcdata.
Document Date
CLEAR w_bdcdata.
w_bdcdata-fnam = 'RM07I-BLDAT'.
w_bdcdata-fval = lw_datum.
APPEND w_bdcdata TO t_bdcdata.
Plant
CLEAR w_bdcdata.
w_bdcdata-fnam = 'IKPF-WERKS'.
w_bdcdata-fval = w_stck_cnt-werks.
APPEND w_bdcdata TO t_bdcdata.
Storage Location
CLEAR w_bdcdata.
w_bdcdata-fnam = 'IKPF-LGORT'.
w_bdcdata-fval = w_stck_cnt-lgort.
APPEND w_bdcdata TO t_bdcdata.
LOOP AT t_stck_cnt INTO w_stck_cnt.
Do not submit items with Errors against them
CHECK w_stck_cnt-message NE 'E' AND
w_stck_cnt-zerostck NE 'X'.
"RM220307
lw_count = lw_count + 1.
Input Screen
CLEAR w_bdcdata.
w_bdcdata-program = 'SAPMM07I'.
w_bdcdata-dynpro = '0731'.
w_bdcdata-dynbegin = 'X'.
APPEND w_bdcdata TO t_bdcdata.
Page Down
CLEAR w_bdcdata.
w_bdcdata-fnam = 'BDC_OKCODE'.
w_bdcdata-fval = '=P+'.
APPEND w_bdcdata TO t_bdcdata.
Material
CLEAR w_bdcdata.
w_bdcdata-fnam = 'ISEG-MATNR(01)'.
w_bdcdata-fval = w_stck_cnt-matnr.
APPEND w_bdcdata TO t_bdcdata.
Batch
CLEAR w_bdcdata.
w_bdcdata-fnam = 'ISEG-CHARG(01)'.
w_bdcdata-fval = w_stck_cnt-charg.
APPEND w_bdcdata TO t_bdcdata.
IF w_stck_cnt-menge NE 0.
Quantity
CLEAR w_bdcdata.
w_bdcdata-fnam = 'ISEG-ERFMG(01)'.
w_bdcdata-fval = w_stck_cnt-menge.
APPEND w_bdcdata TO t_bdcdata.
*-- Begin RM220307 - We need to create an item when the quantity is zero
*-- in file and is non-zero in SAP
ELSE.
Zero Stock indicator
CLEAR w_bdcdata.
w_bdcdata-fnam = 'ISEG-XNULL(01)'.
w_bdcdata-fval = 'X'.
APPEND w_bdcdata TO t_bdcdata.
*-- End RM220307
ENDIF.
ENDLOOP.
CHECK lw_count NE 0.
After all line items have been input
Final Screen
CLEAR w_bdcdata.
w_bdcdata-program = 'SAPMM07I'.
w_bdcdata-dynpro = '0731'.
w_bdcdata-dynbegin = 'X'.
APPEND w_bdcdata TO t_bdcdata.
Save Document
CLEAR w_bdcdata.
w_bdcdata-fnam = 'BDC_OKCODE'.
w_bdcdata-fval = '=BU'.
APPEND w_bdcdata TO t_bdcdata.
CALL TRANSACTION 'MI09' USING t_bdcdata
MODE p_mode
MESSAGES INTO t_messtab.
ENDFORM. " bdc_mi09
*& Form bdc_report
Write BDC Messages.
FORM bdc_report.
DATA: lw_text TYPE t100-text.
SKIP.
WRITE: / text-b01.
WRITE: / sy-uline(21).
SKIP.
Write BDC Messages
LOOP AT t_messtab INTO w_messtab WHERE msgspra = sy-langu.
MESSAGE ID w_messtab-msgid TYPE w_messtab-msgtyp
NUMBER w_messtab-msgnr
WITH w_messtab-msgv1
w_messtab-msgv2
w_messtab-msgv3
w_messtab-msgv4
INTO lw_text.
WRITE: / lw_text.
ENDLOOP.
ENDFORM. " bdc_report
*& Form process_checks
Perform process check before creating BDC Session
FORM process_checks.
DATA: lw_clabs LIKE mchb-clabs,
lw_menge LIKE mchb-clabs,
lw_matnr LIKE mara-matnr,
lw_charg LIKE mch1-charg,
lw_fail,
lw_vfdat TYPE mch1-vfdat,
lv_sell TYPE c, "RM191006
lv_qty(8) TYPE c. "RM191006
CLEAR: d_stck_cnt[], d_stck_cnt. "RM191006
Check if any of the stock figures differ from current stock figures
LOOP AT t_stck_cnt INTO w_stck_cnt.
lw_menge = w_stck_cnt-menge.
SELECT SINGLE clabs INTO lw_clabs
FROM mchb
WHERE matnr = w_stck_cnt-matnr
AND werks = w_stck_cnt-werks
AND lgort = w_stck_cnt-lgort
AND charg = w_stck_cnt-charg.
IF sy-subrc = 0.
IF lw_clabs NE lw_menge.
lw_fail = 'X'.
*-- Begin RM220307 - Do not create PI item if the stock is zero in the
*-- file and is zero in SAP
EXIT.
ELSEIF lw_clabs = 0 AND lw_menge = 0.
w_stck_cnt-zerostck = 'X'.
MODIFY t_stck_cnt FROM w_stck_cnt.
ENDIF.
*-- End RM220307
ELSE.
lw_fail = 'X'.
ERROR
ENDIF.
ENDLOOP.
If no differences are found set NO CHANGE Flag
IF lw_fail NE 'X'.
w_no_change = 'X'.
EXIT.
ENDIF.
Check for Errors in file data
LOOP AT t_stck_cnt INTO w_stck_cnt.
CLEAR lv_sell. "RM191006
SELECT SINGLE matnr INTO lw_matnr
FROM mara
WHERE matnr = w_stck_cnt-matnr.
IF sy-subrc NE 0.
Invalid Material (E)
w_stck_cnt-message = 'E'.
w_stck_cnt-msg_txt = 'Invalid Material'.
MODIFY t_stck_cnt FROM w_stck_cnt.
CONTINUE.
ENDIF.
SELECT SINGLE charg vfdat
INTO (lw_charg, lw_vfdat)
FROM mch1 "KOB01 - changed from MCHA
WHERE matnr = w_stck_cnt-matnr
AND charg = w_stck_cnt-charg.
AND werks = w_stck_cnt-werks.
IF sy-subrc NE 0.
Invalid Material Batch (E)
w_stck_cnt-message = 'E'.
CONCATENATE 'Invalid Material Batch for plant' w_stck_cnt-werks
INTO w_stck_cnt-msg_txt SEPARATED BY space.
MODIFY t_stck_cnt FROM w_stck_cnt.
CONTINUE.
ELSE.
IF w_stck_cnt-vfdat <> lw_vfdat.
Sell by dates do not match (W)
w_stck_cnt-message = 'W'.
w_stck_cnt-msg_txt =
'Sell by Date does not match Shelf life Expiry Date'.
MODIFY t_stck_cnt FROM w_stck_cnt.
lv_sell = 'X'. "RM191006
CONTINUE. "RM191006
ENDIF.
ENDIF.
IF w_stck_cnt-quarn > 0.
Quarantine balance not Zero (W)
w_stck_cnt-message = 'W'.
*-- Begin RM191006
*-- We do want all warning messages on the report
lv_qty = w_stck_cnt-quarn.
CONDENSE lv_qty NO-GAPS.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = lv_qty
IMPORTING
output = lv_qty.
w_stck_cnt-msg_txt = 'Quarantine balance is not zero'.
CONCATENATE 'Quarantine balance is ' lv_qty '- not zero'
INTO w_stck_cnt-msg_txt SEPARATED BY space.
MODIFY t_stck_cnt FROM w_stck_cnt.
CONTINUE.
IF lv_sell = 'X'.
APPEND w_stck_cnt TO d_stck_cnt.
CLEAR lv_sell.
ELSE.
MODIFY t_stck_cnt FROM w_stck_cnt.
ENDIF.
*-- End RM191006
ENDIF.
ENDLOOP.
*-- Begin RM191006
*-- Finally get all the records into dummy table to report
APPEND LINES OF t_stck_cnt TO d_stck_cnt.
SORT d_stck_cnt.
DELETE ADJACENT DUPLICATES FROM d_stck_cnt.
*-- End RM191006
ENDFORM. " process_checks
*& Form file_check_report
Write warning and Error messages from File checks
FORM file_check_report.
WRITE: /2 'Material',
22 'Batch',
32 'Sell By',
45 'Message Text'.
WRITE: /2 sy-uline(115).
SKIP.
LOOP AT t_stck_cnt INTO w_stck_cnt. "RM191006
LOOP AT d_stck_cnt INTO w_stck_cnt. "RM191006
CHECK w_stck_cnt-message NE ' '.
WRITE: /2 w_stck_cnt-matnr,
22 w_stck_cnt-charg,
32 w_stck_cnt-vfdat,
43 w_stck_cnt-message,
45 w_stck_cnt-msg_txt.
ENDLOOP.
ENDFORM. " file_check_report
*& Form post_process_checks
Check Material Batches in SAP against NP File
FORM post_process_checks.
RANGES: r_matnr FOR mchb-matnr,
r_lgort FOR mchb-lgort,
r_werks FOR mchb-werks.
SORT t_stck_cnt.
LOOP AT t_stck_cnt INTO w_stck_cnt.
AT END OF matnr.
r_lgort-sign = 'I'.
r_lgort-option = 'EQ'.
r_lgort-low = w_stck_cnt-lgort.
APPEND r_lgort.
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-low = w_stck_cnt-werks.
APPEND r_werks.
r_matnr-sign = 'I'.
r_matnr-option = 'EQ'.
r_matnr-low = w_stck_cnt-matnr.
APPEND r_matnr.
ENDAT.
ENDLOOP.
Select all material batches for NP Materials
SELECT matnr charg clabs
INTO TABLE t_batch_errors
FROM mchb
WHERE werks IN r_werks
AND lgort IN r_lgort.
IF sy-subrc EQ 0.
Check if the Material Batches are in the NP file
LOOP AT t_batch_errors INTO w_batch_errors.
Disregard Batches without positive unrestricted stock
IF w_batch_errors-clabs LE 0.
DELETE t_batch_errors.
CONTINUE.
ENDIF.
READ TABLE t_stck_cnt INTO w_stck_cnt
WITH KEY matnr = w_batch_errors-matnr
charg = w_batch_errors-charg.
IF sy-subrc = 0.
DELETE t_batch_errors.
ENDIF.
ENDLOOP.
ENDIF.
CHECK NOT t_batch_errors[] IS INITIAL.
Write Batch chak results to report
SKIP.
WRITE: / text-b02.
WRITE: / sy-uline(74).
WRITE: /2 'Material',
22 'Batch'.
WRITE: /2 sy-uline(32).
SKIP.
LOOP AT t_batch_errors INTO w_batch_errors.
WRITE: /2 w_batch_errors-matnr,
22 w_batch_errors-charg.
ENDLOOP.
ENDFORM. " post_process_checks
G E T _ I N T E R F A C E _ F I L E N A M E
FORM get_interface_filename USING filename lw_path.
DATA: i_file TYPE filename-fileintern,
out_filename LIKE v_path-pathextern.
CLEAR: out_filename.
i_file = filename.
get the interface filename to be used when creating file
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
logical_filename = i_file
IMPORTING
file_name = out_filename
EXCEPTIONS
file_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
MOVE out_filename TO lw_path.
IF filename NE c_archive_file. "RM080107
CONCATENATE lw_path 'NP_StockBalance.dat'
INTO lw_path.
*-- Begin RM080107 - Add timestamp to the archived file
ELSE.
CONCATENATE lw_path 'NP_StockBalance' sy-datum sy-uzeit '.dat'
INTO lw_path.
ENDIF.
*-- End RM080107
ELSE.
ENDIF.
ENDFORM. "get_interface_filename
*& Form move_file RM080107
Move the processed file to archive directory
FORM move_file.
*-- At last move the file to archive directory
OPEN DATASET p_arch FOR OUTPUT IN TEXT MODE.
IF sy-subrc = 0.
LOOP AT t_rawdata INTO w_rawdata.
TRANSFER w_rawdata TO p_arch.
ENDLOOP.
ENDIF.
CLOSE DATASET p_arch.
DELETE DATASET p_file.
ENDFORM. " move_file
Best regards,
Prashant

Similar Messages

  • Accidentally removed from,sharing and permissions the admin user,and now i do not when i find the home icon at my computer i do not have permmission,and the mac does not works properly,lots of question mark at the dock ,please help

    accidentally removed from,sharing and permissions the admin user,and now i do not when i find the home icon at my computer i do not have permmission,and the mac does not works properly,lots of question mark at the dock ,please help

    I'm going to assume that since you deleted your hard drive and all its files, you had a backup, yes? If the backup has an OS (bootable clone), then you can boot into it by holding down the option key when you start up you iMac and choose the backup drive. Then use Carbon Copy Cloner or Super Duper to copy the files back to your iMac.

  • SAP Inbox t code sbwp  is not working properly

    Hi,
    In our SAP server the SAP mail box t code SBWP is not working at a particular time between 11 AM to 12 AM. If we send internal mails between SAP users in t code SBWP we are able to receive all the time but at a particular time of 11 AM to 12 AM we are not able to receive any mail.
    If we send any mail at that particular time after 11 AM we are  receiving it only after 12 AM, but this error we are not facing expect that particular time.
    I have checked whether any backgroung work process is Active at that time but all the BG work process are free at that time
    please help me how to solve this issue.
    Thanks
    Senthil

    hi
    check out this sap note
    1348288 Delayed delivery of documents in SBWP

  • I have downloaded PDF Converter and its not working properly

    the pdf I am attempting to convert to edit is not working. I have converted it to all that is available and the lines are off  in someplaces and some data is in the wrong place when I try to Move it I can't or it makes it worse. what can I do?

    As Pat said, which PDF Convertor are you reffereing to here? Which adobe application are you using for the same? What's the operating system that you are using?

  • I have hp g series its spyker not working properly pls give me any solution

    i have hp pavilion g series. i was listening music first its left spesker turn off and after its both speaker turn off. i have cheaked all settings the all settings are correct pls give me any sollution.

    I do not really know much about this kind of problem, but i may be your internet connection.
    If you are on your own #G network then:
    Go to Settings > then enable "Airplane Mode". Count to 10 and then disable it.
    Then wait patiently until you get a good connection and then try again.
    If you are on a nearby Wi-Fi connection then:
    Go to Settings > Wi-Fi > then disable then enable after counting to 10. Make sure that you are connected and then try again.
    If all else fails, then you need to contact your provider for assistance.
    Sprint:888-211-4727
    AT&T:?
    Verizon:?

  • TS4579 since i have installed os X  safari is not working properly and thunderbolt firmware update keps reappearing even though i have done the update .....

    Can anybody Help me ,
    my Mac was working great til i decided to update to OS X Mavericks and i ran the update and since then my Safari is crashing all the time and freezing too, i had to download opera which is working fine , and the update thunderbolt firmware keeps reappearing although i have done couple of times ...
    I wish i didnt

    bunjamin wrote:
    There is now a new line in BBM that wasn't there before which covers the message that I am typing, so I can't actually see what I am typing.
    Hi bunjamin,
    just go to BlackBerry World, and update all your apps including BBM.
    bunjamin wrote:
    Every time I unlock my phone, my screen enlarges so I can't really see much on the hub/notification screen and it defaults to the hub which it didn't do before).
    you can turn off the magnifying glass :
    device settings >> accessibility >> magnify mode >> OFF
    you can deactivate the "reset to Hub view" :
    hub >> overflow (bottom right button) >> Settings >> Display and actions >> Return to Default View When Idle >> OFF
    bunjamin wrote:
    my ringtone is much softer than it was previously
    yes, BlackBerry has acknowledged this bug in this article from the public knowledge base:
    KB36755 After upgrading BlackBerry 10 OS to version 10.3.1 the volume for notifications is noticed to be significantly lower than in the previous version
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

  • I have a redemption code that won't work

    I have a redemption code that will not work. How can I resolve this?

    Go here and choose the Chat option:
    Contact Customer Care

  • I have lost track of the number of websites that do not work properly on the iPad without Adobe Flash player which is unsupported. I cannot use retail sites, billing sites and most important of all job application sites. All are missing tabs, links, info

    I have lost track of the number of websites which do not work properly on my iPad. They include retail sites, billing sites and most important of all job application sites. They all seem to require Adobe Flash Player which cannot be downloaded onto an iPad. Skyfire does not solve the problem. They all load without vital parts of the site such as tabs, links and correct formatting. Any suggestions?

    Most such brower/service combinations have a difficult time working with Flash-based apps and often fail completely. Flash videos are usually the most successful content these browers can handle. You can try the others apps - Puffin, iSwifter, etc - but you may find that none of them work, in which case you will not be able to use your iPad with these sites other than by using one of the various remote control solutions to take over a computer running the full Flash Player.
    IMHO, any developer that built a Flash application for a billing or job application site was an idiot, but I know that's out of the control of anyone but the relevant company.
    Regards.

  • TS3367 I cannot get my iPhone 4S to connect to iMessage n FaceTime have tried all the tips online and it's still not working ? It's just saying  waiting for activation

    I cannot get my iPhone 4S to connect to iMessage n FaceTime have tried all the tips online and it's still not working ? It's just saying  waiting for activation

    What tips have you tried so far?   Just so we don't waste our time telling you things you've already done.
    When you respond, also indicate which country and carrier you're using.   Also, is your phone brand new?  can you make a phone call / access the internet while on cellular?

  • How do I set up a mail group on mac mail?  All the advise on line seems to refer to 'address book' and I only have 'contacts'.  The guidance does not work when using 'contacts' - can anyone help me?

    How do I set up a mail group on mac mail?  All the advise on line seems to refer to 'address book' and I only have 'contacts'.  The guidance does not work when using 'contacts' - can anyone help me?

    Create a group and send mail
    http://www.dummies.com/how-to/content/how-to-create-a-basic-contact-group-in-mac -os-x-li.html
    http://www.macworld.com/article/1165582/how_to_email_groups_with_mail.html
    Best.

  • My apple tv, all of a sudden, is no longer able to connect to my computer.  I have restarted EVERYTHING, multiple times, still not working.

    My apple tv, all of a sudden, is no longer able to connect to my computer.  I have restarted EVERYTHING, multiple times, still not working.

    Welcome to the Apple Community.
    Check your store location is set correctly, if this doesn't help, try restarting the Apple TV by removing ALL the cables for a 30 seconds.

  • I transfered my contacts from my iphone 4s to 5s, all contacts have been transfered but they are not displayed completely in my viber contact list. Actually in my viber contact list there are only those contacts who are from iphones! Please help

    I transfered my contacts from my iphone 4s to 5s, all contacts have been transfered but they are not displayed completely in my viber contact list. Actually in my viber contact list there are only those contacts who are from iphones! Please help

    How did you transfer these contacts from one device to the other?

  • Have been trying all weekend to upload Jpegs- either Send does not work or shows files uploading then shows error- never had this problem with Send Now-16 images total size 92MB-largest image 13MB

    Have been trying all weekend to upload Jpegs- either Send does not work or shows files uploading then shows error- never had this problem with Send Now-16 images total size 92MB-largest image 13MB

    Hi Ciaran19,
    Are you sending files from the Adobe Send interface, Adobe Reader, or the Outlook plug-in?
    Have you checked to see whether the files that you're sending appear in the Recent Files/Sent Files list when you're logged on to https://cloud.acrobat.com? (It could be that they're uploading, but not being sent.)
    It would also be worthwhile to send the files in smaller batches, to see whether a particular file or files is problematic, and causing the error.
    Please let us know how it goes. If you're still having trouble, please let us know where you're sending from, and whether you're able to send the files in smaller batches. It would also be helpful to know the exact error message that you're receiving.
    Best,
    Sara

  • FireFox auto updated to 6.0 this weekend and has not worked properly since. I have uninstalled and reinstalled. Made sure all windows componets were up to date and still no joy. Any idea? Windows 7, 64 bit, normal configfuration. It is extreamly slow.

    FireFox auto updated to 6.0 this weekend and has not worked properly since. I have uninstalled and reinstalled. Made sure all windows componets were up to date and still no joy. Any idea? Windows 7, 64 bit, normal configfuration. It is extreamly slow and never finishes loading ANY page.

    I have had a similar problem with my system. I just recently (within a week of this post) built a brand new desktop. I installed Windows 7 64-bit Home and had a clean install, no problems. Using IE downloaded an anti-virus program, and then, because it was the latest version, downloaded and installed Firefox 4.0. As I began to search the internet for other programs to install after about maybe 10-15 minutes my computer crashes. Blank screen (yet monitor was still receiving a signal from computer) and completely frozen (couldn't even change the caps and num lock on keyboard). I thought I perhaps forgot to reboot after an update so I did a manual reboot and it started up fine.
    When ever I got on the internet (still using firefox) it would crash after anywhere between 5-15 minutes. Since I've had good experience with FF in the past I thought it must be either the drivers or a hardware problem. So in-between crashes I updated all the drivers. Still had the same problem. Took the computer to a friend who knows more about computers than I do, made sure all the drivers were updated, same problem. We thought that it might be a hardware problem (bad video card, chipset, overheating issues, etc.), but after my friend played around with my computer for a day he found that when he didn't start FF at all it worked fine, even after watching a movie, or going through a playlist on Youtube.
    At the time of this posting I'm going to try to uninstall FF 4.0 and download and install FF 3.6.16 which is currently on my laptop and works like a dream. Hopefully that will do the trick, because I love using FF and would hate to have to switch to another browser. Hopefully Mozilla will work out the kinks with FF 4 so I can continue to use it.
    I apologize for the lengthy post. Any feedback would be appreciated, but is not necessary. I will try and post back after I try FF 3.16.6.

  • I have updated my iphone and all  data have gone including photos contacts and notes .is there any solution? I am about to syncope!

    I have updated my iphone4 and all  data have gone including photos contacts and notes .is there any solution?

    All data that was on your iPhone should be on your computer.
    All photos that were transferred to your iPhone from your computer should remain on your computer and can be retransferred. Photos/videos captured by the iPhone can and should be imported by your computer as with any other digital camera - especially before installing an iOS update. Re-transfer these photos from your computer as with any other photos available on your computer.
    Contacts and notes are designed to be synced with a supported application on your computer, and there are some free email accounts that support syncing contacts and notes over the air.

Maybe you are looking for

  • Invoking a LiveCycle process with multiple input variables using REST

    Hi all, A simple scenario brushup: I have an LC process that takes as input 2 parameters: - formID - formXML The user starts out with an empty interactive form and fills out some info in this form. In the end he/she clicks submit and now I want to in

  • SAP PI File Adapter Configuration

    Hi    When i configured and executed one simple file to file scenario , the following error is displaying in Adapter Monitoring..can any one help me in this case.. Sender Adapter v2307 for Party '', Service 'Test_BussSys1': Configured at 2007-10-31 1

  • Connecting old ipod to stereo amp & volumes

    i have connected an old ipod nano 2gb to my main amp and speaker system . The ipod volume is at 100% and is sort of ok to listen to but produces less volume than when using other input sources such as an fm tuner or xm radio. QUESTION: does the age o

  • Une erreur est survenue dans l'App Store. Veuillez réessayer ultérieurement. (20)

    when i want to upgrade ibooks author via the App Store  i get this error message an error occurred  into App Store , please try again later (20) absolutely locked , unable to do anything else what is wrong ? currently running on mavericks 10.9.5 and

  • Update MySQL & PHP Version

    I have a Mac Mini that I am using as a server and I can't figure out how to go about updating the MySQL & PHP that is controlled by the ServerAdmin app. Any ideas?