Sie sind auf Seite 1von 3

SAP Community Network Wiki - Code Gallery - Sample Code BAPI_INSPOPER_R...

Page 1 of 3

Welcome, Guest
Login
Register
Getting Started
Newsletters
Store

Solutions
Services & Support
About SCN
Downloads
Industries
Training & Education
Partnership
Developer Center
Lines of Business
University Alliances
Events & Webinars
Innovation

Sample Code BAPI_INSPOPER_RECORDRESULTS


Added by Rachmad Kurniawan, last edited by Craig Cmehil on Mar 24, 2009
Actually in Tx-Code QE11 we can fill input for result in inspection characteristic, this program provide us to fill result inspection characteristic based on a inspection lot , operation code and inspection point which we can fill
inspection point.
- Automatically fill Evaluation ( Reject or Accept ) depend on our value.
- We can fill whatever inspection point ( depend on your case ).
----------- BEGIN OF CODE ----------------------------------*&---------------------------------------------------------------------*
*& Report ZTEST4
*&
*&---------------------------------------------------------------------*
*& Assign Result for characteristic and create inspection point
*& Created by : Rachmad Kurniawan
*& Indonesian
*& Company Jogja Global Technology - www.jogjaglobaltech.com
*&---------------------------------------------------------------------*
REPORT ztest4.
DATA : l_return LIKE bapiret2 OCCURS 0,
return LIKE bapiret2.
DATA : l_single_result LIKE bapi2045d4 ,
l_single_results LIKE bapi2045d4 OCCURS 0 WITH HEADER LINE.
DATA : l_char_results LIKE bapi2045d2 OCCURS 0,
l_char_resultsnew LIKE bapi2045d2 OCCURS 0,
l_char_result LIKE bapi2045d2,
l_sample_results LIKE bapi2045d3 OCCURS 0,
l_sample_results_new LIKE bapi2045d3 OCCURS 0,
l_sample_result LIKE bapi2045d3,
l_operation LIKE bapi2045l2.
DATA : l_inspoint LIKE bapi2045l4,
l_inspoints LIKE bapi2045l4 OCCURS 0 WITH HEADER LINE,
l_inspointsnew LIKE bapi2045l4 OCCURS 0 WITH HEADER LINE.
*DATA : lv_insplot LIKE bapi2045l2-insplot VALUE '030000000811',
*

lv_insoper LIKE bapi2045l2-inspoper VALUE '0030'.

DATA : l_qapo LIKE qapo,


l_qals LIKE qals.
DATA : BEGIN OF l_type,
unit(3) TYPE c,
unitc(3) TYPE c,
unitt(20) TYPE c,
END OF l_type.
DATA : BEGIN OF l_range,
merknr TYPE qmerknrp, "inspchar
toleranzob TYPE qtolob, "upper limit
toleranzun TYPE qtolun, "belowe limit
END OF l_range.
DATA : l_up TYPE p DECIMALS 2,
l_dw TYPE p DECIMALS 2.
SELECTION-SCREEN BEGIN OF BLOCK insplot WITH FRAME TITLE text-010.
PARAMETERS : pa_insp TYPE bapi2045l2-insplot DEFAULT '030000000811' OBLIGATORY,
pa_inso TYPE bapi2045l2-inspoper DEFAULT '0030' OBLIGATORY.
SKIP.
PARAMETERS : pa_inst(6) TYPE n.
SELECTION-SCREEN END OF BLOCK insplot.

http://wiki.sdn.sap.com/wiki/display/Snippets/Sample+Code+BAPI_INSPOPER_RECO... 6/7/2013

SAP Community Network Wiki - Code Gallery - Sample Code BAPI_INSPOPER_R...

Page 2 of 3

SELECTION-SCREEN BEGIN OF BLOCK inspchar WITH FRAME TITLE text-020.


PARAMETERS : pa_insc(4) TYPE n OBLIGATORY,
pa_valu(22) OBLIGATORY.
SELECTION-SCREEN END OF BLOCK inspchar.
CALL FUNCTION 'BAPI_INSPOPER_GETDETAIL'
EXPORTING
insplot

= pa_insp

inspoper

= pa_inso

read_insppoints

= 'X'

read_char_requirements

=''

read_char_results

= 'X'

read_sample_results

= 'X'

read_single_results

= 'X'

read_chars_with_classes

=''

read_chars_without_recording = ' '


res_org

=''

char_filter_no

= '1'

max_insppoints

= 100

insppoint_from

=0

handheld_application

=''

IMPORTING
operation

= l_operation

return

= return

TABLES
insppoints

= l_inspoints

char_results

= l_char_results

sample_results

= l_sample_results

single_results

= l_single_results.

.
*BREAK-POINT.
*get unit text and unit iso code
CALL FUNCTION 'QIBP_GET_OPERATION'
EXPORTING
i_insp_lot

= pa_insp

i_insp_lot_operation = pa_inso
IMPORTING
e_qapo

= l_qapo

e_qals

= l_qals

EXCEPTIONS
wrong_inspection_lot = 1
wrong_operation

=2

operation_not_unique = 3.
*get upper limit or below limit from PLMK table
SELECT SINGLE merknr toleranzob toleranzun INTO CORRESPONDING FIELDS OF l_range FROM
plmk WHERE plnty = l_qapo-plnty AND
plnnr = l_qapo-plnnr AND
plnkn = l_qapo-pplnkn AND
merknr = pa_insc.
MOVE l_range-toleranzob TO l_up.
MOVE l_range-toleranzun TO l_dw .
LOOP AT l_sample_results INTO l_sample_result WHERE inspchar = pa_insc.
l_sample_result-mean_value = pa_valu.
IF ( l_sample_result-inspchar = l_range-merknr ).
IF pa_valu > l_up.
l_sample_result-evaluated = 'X'.
l_sample_result-closed = ' '.
l_sample_result-evaluation = 'R'.
elseif pa_valu < l_dw .
l_sample_result-evaluated = 'X'.
l_sample_result-closed = ' '.
l_sample_result-evaluation = 'R'.
ELSE.
l_sample_result-evaluated = 'X'.
l_sample_result-closed = ' '.
l_sample_result-evaluation = 'A'.
ENDIF.
ENDIF.
APPEND l_sample_result TO l_sample_results_new.
ENDLOOP.
*take unit and text and iso code measurement from table master uom.
SELECT SINGLE a~msehi a~isocode b~msehl INTO l_type FROM t006 AS a
INNER JOIN t006a AS b ON a~msehi = b~msehi WHERE a~msehi = l_qals-mengeneinh
AND b~spras = sy-langu.
*tentukan inpection lot bila tidak ada otomatis buat inspection lot
IF sy-subrc = 0.
* l_inspoint-insppoint = '000001'.
l_inspoint-insppoint = pa_inst.
l_inspoint-insplot = pa_insp.

http://wiki.sdn.sap.com/wiki/display/Snippets/Sample+Code+BAPI_INSPOPER_RECO... 6/7/2013

SAP Community Network Wiki - Code Gallery - Sample Code BAPI_INSPOPER_R...

Page 3 of 3

l_inspoint-inspoper = pa_inso.
l_inspoint-userc1 = pa_inst.
* l_inspoint-userc1 = '000000000000000001'.
l_inspoint-unit = l_type-unit.
l_inspoint-unitc = l_type-unitc.
l_inspoint-unitt = l_type-unitt.
ENDIF.
BREAK-POINT.
CALL FUNCTION 'BAPI_INSPOPER_RECORDRESULTS'
EXPORTING
insplot
inspoper
insppointdata

= pa_insp
= pa_inso
= l_inspoint

IMPORTING
return

= return

TABLES
* char_results
sample_results

= l_char_resultsnew
= l_sample_results_new

* single_results
returntable

= l_single_results
= l_return.

*for quantity value gunakan sample result


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = ' '.
-------------- END OF CODE -------------------

Labels
abap

Comments (1)

Follow SCN
Contact Us
SAP Help Portal

Privacy
Terms of Use
Legal Disclosure
Copyright

http://wiki.sdn.sap.com/wiki/display/Snippets/Sample+Code+BAPI_INSPOPER_RECO... 6/7/2013