Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

FUNCTIONALITY FOR GETTING THE VARIANT CHARACTERISTICS
Functional Module: ZSD_SO_CHARACTERISTICS.
Input Tables: IST_SO_DETAILS, IST_CHARS
Output Table: IST_VARIANT_CHARS
Purpose: This Functional Module is used to get the Variant Characteristics for a given Sale Order/Item and for specified Characteristics.
Benefits over the Standard Function module VC_I_GET_CONFIGURATION:
(1)It saves the lot of Execution time.
(2)It prevents the Dump like Paging Memory .
 Required structures for the input and output table parameters for Function module ZSD_SO_CHARACTERISTICS.
 
(1)Create a structure for ZSD_SOITEM as shown below in SE11. 

Component

Component Type

Data Type

Length

Description

VBELN

VBELN

CHAR

10

Sales and Distribution Document Number

POSNR

POSNR

NUMC

6

Item number of the SD document

        
(2)Create a structure for ZSD_CHARS as shown below in SE11.
 

Component

Component Type

Data Type

Length

Description

ATNAM

ATNAM

CHAR

30

Characteristic Name

 

 

(3)Create a structure for ZSD_VARIANT_CHARS as shown below in SE11.

Component

Component Type

Data Type

Length

Decimal

Description

VBELN

VBELN

CHAR

10

 

Sales and Distribution Document No.

POSNR

POSNR

NUMC

6

 

Item number of the SD document

ATINN

ATINN

NUMC

10

 

Internal characteristic

ATNAM

ATNAM

CHAR

30

 

Characteristic Name

ATWRT

ATWRT

CHAR

30

 

Characteristic Value

ATFLV

ATFLV

FLTP

16

16

Internal floating point from


How to use this Function module:-

Error rendering macro 'code': Invalid value specified for parameter 'lang'
*********************DATA DECLARATION**********************
DATA: IST_SO_TEMP    TYPE STANDARD TABLE OF ZSD_SOITEM,
      W_SO_TEMP      TYPE ZSD_SOITEM,
      IST_CHARS_TEMP TYPE STANDARD TABLE OF ZSD_CHARS,
      W_CHARS_TEMP   TYPE ZSD_CHARS,
      IST_VARIANT_CHARS_TEMP TYPE STANDARD TABLE OF ZSD_VARIANT_CHARS,
      W_VARIANT_CHARS_TEMP   TYPE ZSD_VARIANT_CHARS.
* ***********FILLING THE INPUT INTERNAL TABLES ************
LOOP AT IST_FINAL INTO W_FINAL.
* *IST_FINAL IS A FINAL INTERNAL TABLE FOR OUTPUT.
  UNPACK W_FINAL-VBELN TO W_FINAL-VBELN.
  W_SO_TEMP-VBELN = W_FINAL-VBELN.
  W_SO_TEMP-POSNR = W_FINAL-POSNR.
  APPEND W_SO_TEMP TO IST_SO_TEMP.
ENDLOOP.
CLEAR W_CHARS_TEMP.
W_CHARS_TEMP = 'A_THICK_MM'.
APPEND W_CHARS_TEMP TO IST_CHARS_TEMP.
CLEAR W_CHARS_TEMP.
W_CHARS_TEMP = 'A_WIDTH_MM'.
APPEND W_CHARS_TEMP TO IST_CHARS_TEMP.
CLEAR W_CHARS_TEMP.
W_CHARS_TEMP = 'A_PRODUCT_FORM'.
APPEND W_CHARS_TEMP TO IST_CHARS_TEMP.
CLEAR W_CHARS_TEMP.
W_CHARS_TEMP = 'A_LENGTH_MM'.
APPEND W_CHARS_TEMP TO IST_CHARS_TEMP.
* ***********CALLING THE FUNCTION MODULE ************
CALL FUNCTION 'ZSD_SO_CHARACTERISTICS'
TABLES
  IST_SO_DETAILS    = IST_SO_TEMP             *INPUT INTERNAL TABLE
  IST_CHARS         = IST_CHARS_TEMP          *INPUT INTERNAL TABLE
          IST_VARIANT_CHARS = IST_VARIANT_CHARS_TEMP.
* *OUTPUT INTERNAL TABLE
***********USE OF OUTPUT INTERNAL TABLE ************
SORT IST_VARIANT_CHARS_TEMP BY VBELN POSNR ATNAM.
LOOP AT IST_FINAL INTO W_FINAL. "IST_FINAL is a Final Internal Table.
  CLEAR W_VARIANT_CHARS_TEMP.
  READ TABLE IST_VARIANT_CHARS_TEMP INTO W_VARIANT_CHARS_TEMP
  WITH KEY VBELN = W_FINAL-VBELN
   POSNR = W_FINAL-POSNR
   ATNAM = 'A_THICK_MM'  BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    W_FINAL-THICKNESS = W_VARIANT_CHARS_TEMP-ATFLV.
  ENDIF.
  CLEAR W_VARIANT_CHARS_TEMP.
  READ TABLE IST_VARIANT_CHARS_TEMP INTO W_VARIANT_CHARS_TEMP
  WITH KEY VBELN = W_FINAL- VBELN
   POSNR = W_FINAL-POSNR
   ATNAM = 'A_WIDTH_MM'  BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    W_FINAL-WIDTH = W_VARIANT_CHARS_TEMP-ATFLV.
  ENDIF.
  CLEAR W_VARIANT_CHARS_TEMP.
  READ TABLE IST_VARIANT_CHARS_TEMP INTO W_VARIANT_CHARS_TEMP
  WITH KEY VBELN = W_FINAL- VBELN
   POSNR = W_FINAL-POSNR
   ATNAM = 'A_LENGTH_MM'  BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    W_FINAL-LENGTH = W_VARIANT_CHARS_TEMP-ATFLV.
  ENDIF.
  CLEAR W_VARIANT_CHARS_TEMP.
  READ TABLE IST_VARIANT_CHARS_TEMP INTO W_VARIANT_CHARS_TEMP
  WITH KEY VBELN = W_FINAL-VBELN
   POSNR = W_FINAL-POSNR
   ATNAM = 'A_PRODUCT_FORM'  BINARY SEARCH.
  IF SY-SUBRC EQ 0.
    W_FINAL-PFORM = W_VARIANT_CHARS_TEMP-ATWRT.
  ENDIF.
ENDLOOP.
**************LOGIC FOR FUNCTION MODULE**************
FUNCTION ZSD_SO_CHARACTERISTICS.
*"---------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      IST_SO_DETAILS STRUCTURE  ZSD_SOITEM
*"      IST_CHARS STRUCTURE  ZSD_CHARS
*"      IST_VARIANT_CHARS STRUCTURE  ZSD_VARIANT_CHARS
*"---------------------------------------------------------------------
  TYPES: BEGIN OF TY_CABN,
          ATINN TYPE ATINN,
          ATNAM TYPE ATNAM,
         END OF TY_CABN.
  TYPES: BEGIN OF TY_VBAP,
          VBELN TYPE VBELN_VA,
          POSNR TYPE POSNR_VA,
          CUOBJ TYPE CUOBJ_VA,
        END OF TY_VBAP.
  TYPES: BEGIN OF TY_IBIN,
          IN_RECNO TYPE IB_RECNO,
          INSTANCE TYPE IB_INSTANCE,
        END OF TY_IBIN.
  TYPES: BEGIN OF TY_IBINVALUES,
          IN_RECNO TYPE IB_RECNO,
          SYMBOL_ID TYPE IBSYMID,
        END OF TY_IBINVALUES.
  TYPES: BEGIN OF TY_IBSYMBOL,
          SYMBOL_ID TYPE IBSYMID,
          ATINN TYPE ATINN,
          ATWRT TYPE ATWRT,
          ATFLV TYPE ATFLV,
        END OF TY_IBSYMBOL.
  TYPES: BEGIN OF TY_VARIANT_CHARS,
          VBELN TYPE VBELN_VA,
          POSNR TYPE POSNR_VA,
          ATINN TYPE ATINN,
          ATNAM TYPE ATNAM,
          ATWRT TYPE ATWRT,
          ATFLV TYPE ATFLV,
         END OF TY_VARIANT_CHARS.
  DATA: IST_CABN TYPE STANDARD TABLE OF TY_CABN,
        W_CABN   TYPE TY_CABN,
        IST_VBAP TYPE STANDARD TABLE OF TY_VBAP,
        W_VBAP   TYPE TY_VBAP,
        IST_IBIN TYPE STANDARD TABLE OF TY_IBIN,
        W_IBIN   TYPE TY_IBIN,
        IST_IBINVALUES TYPE STANDARD TABLE OF TY_IBINVALUES,
        W_IBINVALUES   TYPE TY_IBINVALUES,
        IST_IBSYMBOL   TYPE STANDARD TABLE OF TY_IBSYMBOL,
        W_IBSYMBOL     TYPE TY_IBSYMBOL,
        W_VARIANT_CHARS TYPE ZSD_VARIANT_CHARS.
  DATA: W_SO_DETAILS LIKE LINE OF IST_SO_DETAILS,
        G_INDEX TYPE SY-INDEX.
  RANGES: R_ATINN FOR CABN-ATINN.
  IF IST_SO_DETAILS[] IS INITIAL.
*  RAISE THE EXCEPTION FROM HERE
    EXIT.
  ENDIF.
  IF IST_CHARS[] IS INITIAL.
*  RAISE THE EXCEPTION FROM HERE
    EXIT.
  ENDIF.
  SELECT ATINN ATNAM FROM CABN INTO TABLE IST_CABN
  FOR ALL ENTRIES IN IST_CHARS
  WHERE ATNAM EQ IST_CHARS-ATNAM.
  IF IST_CABN IS INITIAL.
*  RAISE THE EXCEPTION FROM HERE
    EXIT.
  ENDIF.
  LOOP AT IST_CABN INTO W_CABN.
    R_ATINN-LOW = W_CABN-ATINN.
    R_ATINN-HIGH = ' '.
    R_ATINN-SIGN = 'I'.
    R_ATINN-OPTION = 'EQ'.
    APPEND R_ATINN TO R_ATINN.
    CLEAR W_CABN.
  ENDLOOP.
  SELECT VBELN POSNR CUOBJ FROM VBAP INTO TABLE IST_VBAP
  FOR ALL ENTRIES IN IST_SO_DETAILS
  WHERE VBELN EQ IST_SO_DETAILS-VBELN
  AND POSNR EQ IST_SO_DETAILS-POSNR.
  IF NOT IST_VBAP IS INITIAL.
    SELECT IN_RECNO INSTANCE FROM IBIN INTO TABLE IST_IBIN
    FOR ALL ENTRIES IN IST_VBAP
    WHERE INSTANCE EQ IST_VBAP-CUOBJ.
    SORT IST_IBIN BY INSTANCE IN_RECNO DESCENDING.
    DELETE ADJACENT DUPLICATES FROM IST_IBIN COMPARING INSTANCE.
    IF NOT IST_IBIN IS INITIAL.
      SELECT IN_RECNO SYMBOL_ID FROM IBINVALUES INTO TABLE IST_IBINVALUES
      FOR ALL ENTRIES IN IST_IBIN
      WHERE IN_RECNO EQ IST_IBIN-IN_RECNO.
      IF NOT IST_IBINVALUES IS INITIAL.
        SELECT SYMBOL_ID ATINN ATWRT ATFLV FROM IBSYMBOL INTO TABLE
        IST_IBSYMBOL FOR ALL ENTRIES IN IST_IBINVALUES
        WHERE SYMBOL_ID EQ IST_IBINVALUES-SYMBOL_ID
        AND ATINN IN R_ATINN.
      ENDIF.
    ENDIF.
  ELSE.
*  RAISE THE EXCEPTION FROM HERE
    EXIT.
  ENDIF.
  SORT IST_IBSYMBOL BY SYMBOL_ID.
  LOOP AT IST_IBINVALUES INTO W_IBINVALUES.
    G_INDEX = SY-TABIX.
    READ TABLE IST_IBSYMBOL INTO W_IBSYMBOL WITH KEY
    SYMBOL_ID = W_IBINVALUES-SYMBOL_ID BINARY SEARCH.
    IF SY-SUBRC NE 0.
      DELETE IST_IBINVALUES INDEX G_INDEX.
    ENDIF.
  ENDLOOP.
  REFRESH IST_VARIANT_CHARS.
  SORT :  IST_IBIN BY INSTANCE,
          IST_IBSYMBOL BY SYMBOL_ID,
          IST_CABN BY ATINN.
  LOOP AT IST_VBAP INTO W_VBAP.
    CLEAR : W_VARIANT_CHARS, W_IBIN.
    W_VARIANT_CHARS-VBELN = W_VBAP-VBELN.
    W_VARIANT_CHARS-POSNR = W_VBAP-POSNR.
    READ TABLE IST_IBIN INTO W_IBIN
    WITH KEY INSTANCE = W_VBAP-CUOBJ
    BINARY SEARCH.
    LOOP AT IST_IBINVALUES INTO W_IBINVALUES
                         WHERE IN_RECNO EQ W_IBIN-IN_RECNO.
      CLEAR W_IBSYMBOL.
      READ TABLE IST_IBSYMBOL INTO W_IBSYMBOL
      WITH KEY SYMBOL_ID = W_IBINVALUES-SYMBOL_ID
      BINARY SEARCH.
      IF SY-SUBRC EQ 0.
        CLEAR W_CABN.
        READ TABLE IST_CABN INTO W_CABN WITH KEY
        ATINN  = W_IBSYMBOL-ATINN BINARY SEARCH.
        W_VARIANT_CHARS-ATINN = W_IBSYMBOL-ATINN.
        W_VARIANT_CHARS-ATNAM = W_CABN-ATNAM.
        W_VARIANT_CHARS-ATFLV = W_IBSYMBOL-ATFLV.
        W_VARIANT_CHARS-ATWRT = W_IBSYMBOL-ATWRT.
        APPEND W_VARIANT_CHARS TO IST_VARIANT_CHARS.
      ENDIF.
    ENDLOOP.
  ENDLOOP.
ENDFUNCTION.


  

  • No labels