Friday, May 27, 2011

How to get batch characterstics

Combine 18 character material and 10 character batch into OBJEK.
Now pass this OBJEK to table INOB.
pass KLART as '023' - batch
pass OBTAB as 'MCH1'
Now go to AUSP.
Pass the CUOBJ field from the INOB table to OBJEK field.
Here you will get all the characterstics value.
You can get your desired characterstics.
Below is the code for the same.


REPORT  zbatch_characterstics.

TYPES: BEGIN OF d_ausp,
       atinn TYPE ausp-atinn,
       atwrt TYPE ausp-atwrt,
      END OF d_ausp.

DATA: w_matnr TYPE mara-matnr,
      w_charg TYPE lips-charg,
      w_key   TYPE ausp-objek,
      w_cuobj TYPE inob-cuobj,
      w_vinin TYPE ausp-atinn.

DATA: it_ausp TYPE TABLE OF d_ausp.

DATA: wa_ausp TYPE d_ausp.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  EXPORTING
    input        = w_matnr
  IMPORTING
    output       = w_matnr
  EXCEPTIONS
    length_error = 1
    OTHERS       = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'CONVERSION_EXIT_AUFNR_INPUT'
  EXPORTING
    input  = w_charg
  IMPORTING
    output = w_charg.

CONCATENATE w_matnr w_charg INTO w_key.

SELECT SINGLE cuobj
  FROM inob
  INTO w_cuobj
  WHERE klart = '023'
  AND   obtab = 'MCH1'
  AND   objek = w_key.

SELECT atinn atwrt
  FROM ausp
  INTO TABLE it_ausp
  WHERE objek = w_cuobj.

SELECT SINGLE atinn
  INTO w_vinin
  FROM cabn
  WHERE atnam = 'VEHICLE_VIN'.

READ TABLE it_ausp INTO wa_ausp WITH KEY atinn = w_vinin.

** How to get material batch characterstics in sap

No comments: