SAP for Utilities Discussions
Connect with fellow SAP users to share best practices, troubleshoot challenges, and collaborate on building a sustainable energy future. Join the discussion.
cancel
Showing results for 
Search instead for 
Did you mean: 

Inspection lot result based on Serial Number using BAP

Former Member
0 Kudos
887

We have requirement to create meter result and i think most appropritate BAPI for this functionality is BAPI_INSPOPER_RECORDRESULTS.

We want to record results for particular serial number of equipement number(sernr fields in EQUI ).

When we fill online QE01 we get pop up for serial number and then meter result for this number.

When crerating same meter result through BAPI, how and where can I mention this serial number and create serial number specific meter result for inspection lot.

Please can anyone tell me how to record meter result based on device no using BAPI.

7 REPLIES 7

Former Member
0 Kudos
487

You have to pass the serial number value to SAMPLE_RESULTS-EXT_NO field.

0 Kudos
487

Srinivas can you please look into my thread : Quality Management During Goods Receipt (Inspection Lot) as well. Please

Former Member
0 Kudos
487

The field you mentioned is in single_results but even then it is not getting created. May be I am doing something wrong in passing parameters due to my non awareness of QM system.

Can you please help me if you have any sample code for inspection results?

My requirements is that I create a Inspection lot during GR (BAPI) and then I need to record results. Can you please let me know what are the minimum fields required for recording result using Serial Number.

Thanks in advance.

I hope you understand.

0 Kudos
487

I am assuming you already created the lot either within the same program or taking the lot number as input to your program. Once you have the lot number, you will need to call QIBP_INSPOPER_GETLIST passing the lot number to I_INSP_LOT and get the table T_QAPO_TAB. Depending on your scenario, there may one or more operations in the returned table. If there is only one entry in T_QAPO_TAB, then read it index 1 and keep the value of T_QAPO_TAB-VORNR field.

After this call function module BAPI_INSPOPER_GETDETAIL, by passing lot number to INSPLOT, and T_QAPO_TAB-VORNR to INSPOPER and get back CHAR_REQUIREMENTS. Loop at the CHAR_REQUIREMENTS table and fill in the SINGLE_RESULTS as below.

SINGLE_RESULTS-INSPLOT = your inspection lot number

SINGLE_RESULTS-INSPOPRT = T_QAPO_TAB-VORNR

SINGLE_RESULTS-INSPCHAR = CHAR_REQUIREMENTS-INSPCHAR

SINGLE_RESULTS-EXTNO = your serial number

SINGLE_RESULTS-INSP_DATE = your inspection results date

SINGLE_RESULTS-INSP-TIME = your inspection results time

Then depending on if your setting you may need to fill in one way

SINGLE_RESULTS-CODE1 = inspection result value for this characteristic

SINGLE_RESULTS--CODE_GRP1 = whatever it is configured

or if CODE_GRP1 is not needed

SINGLE_RESULTS-RES_VALUE = inspection result value for this characteristic.

You may also want to fill in REMARK field depending on your configuration and requirement.

Append all records and call BAPI_INSPOPER_RECORDRESULTS by passing INSPLOT = your inspection lot and INSPOPER = T_QAPO_TAB-VORNR, and SINGLE_RESULTS table. It is always a good idea with BAPIs to get the return table to see what errors occured (if any). Then call BAPI_TRANSACTION_COMMIT or BAPI_TRANSACTION_ROLLBACK depending on the return table.

0 Kudos
487

I have tried the method you provided. I have some problem and a query.

The problem is i would like to know how to make each characteristics as accepted and also updated inspected value + status ... as if the inspection is over...

Queries is that i am creating one lot per material doc item and so there can be multiple serial number per inspection lot. How can I handle this in the BAPI?

0 Kudos
487

Please see my current code as below and please advice the change as my characteristic is not getting closed or even the characteristics items are not getting approved or the inspected qty getting updated;

**********************************************************************************

LOOP AT t_insplot_list INTO w_insplot_list.

w_charresults-insplot = w_insplot_list-insplot.

w_charresults-inspoper = '0010'.

w_charresults-inspchar = '0010'.

w_charresults-closed = 'X'.

w_charresults-evaluated = 'X'. "

w_charresults-evaluation = 'A'. "Accepted

w_charresults-mean_value = p_insval.

APPEND w_charresults TO t_charresults.

READ TABLE t_ser03 INTO w_ser03 WITH KEY mblnr = w_insplot_list-mat_doc

mjahr = w_insplot_list-doc_year

zeile = w_insplot_list-matdoc_itm.

IF sy-subrc = 0.

w_singleresults-insplot = w_insplot_list-insplot.

w_singleresults-inspoper = '0010'.

w_singleresults-inspchar = '0010'.

  • w_singleresults-insp_date = sy-datum.

  • w_singleresults-insp_time = sy-uzeit.

LOOP AT t_objk INTO w_objk WHERE obknr = w_ser03-obknr.

w_singleresults-ext_no = w_objk-sernr.

APPEND w_singleresults TO t_singleresults.

ENDLOOP.

ENDIF.

CALL FUNCTION 'BAPI_INSPOPER_RECORDRESULTS'

EXPORTING

insplot = w_charresults-insplot

inspoper = w_charresults-inspoper

  • insppointdata = i_inspointdata

  • IMPORTING

  • return = <bapireturn2

TABLES

char_results = t_charresults

  • sample_results = t_sampleresults

returntable = t_bapi_ret

single_results = t_singleresults.

DELETE t_bapi_ret WHERE type NE 'E'.

IF t_bapi_ret[] IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

  • IMPORTING

  • RETURN =

.

ENDIF.

ENDLOOP.

0 Kudos
487

I changed the code to as follows and now it is working for single serial number.

******************************************************************************

LOOP AT t_insplot_list INTO w_insplot_list.

CALL FUNCTION 'BAPI_INSPOPER_GETDETAIL'

EXPORTING

insplot = w_singleresults-insplot

inspoper = w_singleresults-inspoper

  • READ_INSPPOINTS = ' '

read_char_requirements = 'X'

  • READ_CHAR_RESULTS = ' '

  • READ_SAMPLE_RESULTS = ' '

  • READ_SINGLE_RESULTS = ' '

  • READ_CHARS_WITH_CLASSES = ' '

  • READ_CHARS_WITHOUT_RECORDING = ' '

  • RES_ORG = ' '

  • CHAR_FILTER_NO = '1 '

  • CHAR_FILTER_TCODE = 'QE11'

  • MAX_INSPPOINTS = 100

  • INSPPOINT_FROM = 0

  • HANDHELD_APPLICATION = ' '

  • IMPORTING

  • OPERATION =

  • INSPPOINT_REQUIREMENTS =

  • RETURN =

TABLES

  • INSPPOINTS =

char_requirements = t_char_requirements

  • CHAR_RESULTS =

  • SAMPLE_RESULTS =

  • SINGLE_RESULTS =

.

LOOP AT t_char_requirements INTO w_char_requirements.

w_charresults-insplot = w_insplot_list-insplot.

w_charresults-inspoper = w_char_requirements-inspoper.

w_charresults-inspchar = w_char_requirements-inspchar.

w_charresults-closed = 'X'.

w_charresults-evaluated = 'X'. "

w_charresults-evaluation = 'A'. "Accepted

w_charresults-mean_value = p_insval.

APPEND w_charresults TO t_charresults.

READ TABLE t_ser03 INTO w_ser03 WITH KEY mblnr = w_insplot_list-mat_doc

mjahr = w_insplot_list-doc_year

zeile = w_insplot_list-matdoc_itm.

IF sy-subrc = 0.

w_singleresults-insplot = w_insplot_list-insplot.

w_singleresults-inspoper = w_char_requirements-inspoper.

w_singleresults-res_value = p_insval.

  • w_singleresults-insp_date = sy-datum.

  • w_singleresults-insp_time = sy-uzeit.

LOOP AT t_objk INTO w_objk WHERE obknr = w_ser03-obknr.

w_singleresults-inspchar = w_char_requirements-inspchar.

w_singleresults-ext_no = w_objk-sernr.

APPEND w_singleresults TO t_singleresults.

ENDLOOP.

ENDIF.

CALL FUNCTION 'BAPI_INSPOPER_RECORDRESULTS'

EXPORTING

insplot = w_charresults-insplot

inspoper = w_charresults-inspoper

  • insppointdata = i_inspointdata

  • IMPORTING

  • return = <bapireturn2

TABLES

char_results = t_charresults

  • sample_results = t_sampleresults

returntable = t_bapi_ret

single_results = t_singleresults.

DELETE t_bapi_ret WHERE type NE 'E'.

IF t_bapi_ret[] IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'

  • IMPORTING

  • RETURN =

.

ENDIF.

ENDLOOP.

ENDLOOP.