SAP Function Modules

CS_WHERE_USED_DOC SAP Function module - Bills of material; document use







CS_WHERE_USED_DOC is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name CS_WHERE_USED_DOC into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: CSS5
Released Date: Not Released
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM CS_WHERE_USED_DOC - CS WHERE USED DOC





CALL FUNCTION 'CS_WHERE_USED_DOC' "Bills of material; document use
  EXPORTING
    datub =                     " rc29l-datub   Date 'valid to'
    datuv =                     " rc29l-datuv   Date 'valid from'
    docar =                     " draw-dokar    Document type
    docnr =                     " draw-doknr    Document number
    doctl =                     " draw-doktl    Part document
    docvr =                     " draw-dokvr    Document version
*   postp = SPACE               " rc29l-postp   Item category
*   retcode_only = SPACE        " csdata-xfeld  no data - only set return code
*   stlan = SPACE               " rc29l-stlan   BOM usage
*   werks = SPACE               " rc29l-werks   Plant
*   stltp = SPACE               " rc29a-atabr
*   newsi = SPACE               " csdata-xfeld
  IMPORTING
    topdoc =                    " csxdoc        Data on the initial material
  TABLES
    wultb =                     " stpov         WHERE-USED list table (items)
    doccat =                    " cscdoc        Assembly table: documents
    equicat =                   " cscequi       Assembly table: equipments
    kndcat =                    " cscknd        Assembly table: sales orders
    matcat =                    " cscmat        Assembly table: materials
*   prjcat =                    " cscprj
    stdcat =                    " cscstd        Assembly table: standard objects
    tplcat =                    " csctpl        Assembly table: functional locations
  EXCEPTIONS
    CALL_INVALID = 1            "               Function module call incomplete or invalid
    DOCUMENT_NOT_FOUND = 2      "               Document not available
    NO_WHERE_USED_REC_FOUND = 3  "              no where used record available
    NO_WHERE_USED_REC_SELECTED = 4  "           no where used record selected
    NO_WHERE_USED_REC_VALID = 5  "              no valid where used record available
    .  "  CS_WHERE_USED_DOC

ABAP code example for Function Module CS_WHERE_USED_DOC





The ABAP code below is a full code listing to execute function module CS_WHERE_USED_DOC including all data declarations. The code uses the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the original method of declaring data variables up front. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8).

DATA:
ld_topdoc  TYPE CSXDOC ,
it_wultb  TYPE STANDARD TABLE OF STPOV,"TABLES PARAM
wa_wultb  LIKE LINE OF it_wultb ,
it_doccat  TYPE STANDARD TABLE OF CSCDOC,"TABLES PARAM
wa_doccat  LIKE LINE OF it_doccat ,
it_equicat  TYPE STANDARD TABLE OF CSCEQUI,"TABLES PARAM
wa_equicat  LIKE LINE OF it_equicat ,
it_kndcat  TYPE STANDARD TABLE OF CSCKND,"TABLES PARAM
wa_kndcat  LIKE LINE OF it_kndcat ,
it_matcat  TYPE STANDARD TABLE OF CSCMAT,"TABLES PARAM
wa_matcat  LIKE LINE OF it_matcat ,
it_prjcat  TYPE STANDARD TABLE OF CSCPRJ,"TABLES PARAM
wa_prjcat  LIKE LINE OF it_prjcat ,
it_stdcat  TYPE STANDARD TABLE OF CSCSTD,"TABLES PARAM
wa_stdcat  LIKE LINE OF it_stdcat ,
it_tplcat  TYPE STANDARD TABLE OF CSCTPL,"TABLES PARAM
wa_tplcat  LIKE LINE OF it_tplcat .


DATA(ld_datub) = 20210129

DATA(ld_datuv) = 20210129

SELECT single DOKAR
FROM DRAW
INTO @DATA(ld_docar).


SELECT single DOKNR
FROM DRAW
INTO @DATA(ld_docnr).


SELECT single DOKTL
FROM DRAW
INTO @DATA(ld_doctl).


SELECT single DOKVR
FROM DRAW
INTO @DATA(ld_docvr).


DATA(ld_postp) = some text here

DATA(ld_retcode_only) = some text here

DATA(ld_stlan) = some text here

DATA(ld_werks) = some text here

DATA(ld_stltp) = some text here

DATA(ld_newsi) = some text here

"populate fields of struture and append to itab
append wa_wultb to it_wultb.

"populate fields of struture and append to itab
append wa_doccat to it_doccat.

"populate fields of struture and append to itab
append wa_equicat to it_equicat.

"populate fields of struture and append to itab
append wa_kndcat to it_kndcat.

"populate fields of struture and append to itab
append wa_matcat to it_matcat.

"populate fields of struture and append to itab
append wa_prjcat to it_prjcat.

"populate fields of struture and append to itab
append wa_stdcat to it_stdcat.

"populate fields of struture and append to itab
append wa_tplcat to it_tplcat. . CALL FUNCTION 'CS_WHERE_USED_DOC' EXPORTING datub = ld_datub datuv = ld_datuv docar = ld_docar docnr = ld_docnr doctl = ld_doctl docvr = ld_docvr * postp = ld_postp * retcode_only = ld_retcode_only * stlan = ld_stlan * werks = ld_werks * stltp = ld_stltp * newsi = ld_newsi IMPORTING topdoc = ld_topdoc TABLES wultb = it_wultb doccat = it_doccat equicat = it_equicat kndcat = it_kndcat matcat = it_matcat * prjcat = it_prjcat stdcat = it_stdcat tplcat = it_tplcat EXCEPTIONS CALL_INVALID = 1 DOCUMENT_NOT_FOUND = 2 NO_WHERE_USED_REC_FOUND = 3 NO_WHERE_USED_REC_SELECTED = 4 NO_WHERE_USED_REC_VALID = 5 . " CS_WHERE_USED_DOC
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 4. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 5. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_topdoc  TYPE CSXDOC ,
ld_datub  TYPE RC29L-DATUB ,
it_wultb  TYPE STANDARD TABLE OF STPOV ,
wa_wultb  LIKE LINE OF it_wultb,
ld_datuv  TYPE RC29L-DATUV ,
it_doccat  TYPE STANDARD TABLE OF CSCDOC ,
wa_doccat  LIKE LINE OF it_doccat,
ld_docar  TYPE DRAW-DOKAR ,
it_equicat  TYPE STANDARD TABLE OF CSCEQUI ,
wa_equicat  LIKE LINE OF it_equicat,
ld_docnr  TYPE DRAW-DOKNR ,
it_kndcat  TYPE STANDARD TABLE OF CSCKND ,
wa_kndcat  LIKE LINE OF it_kndcat,
it_matcat  TYPE STANDARD TABLE OF CSCMAT ,
wa_matcat  LIKE LINE OF it_matcat,
ld_doctl  TYPE DRAW-DOKTL ,
it_prjcat  TYPE STANDARD TABLE OF CSCPRJ ,
wa_prjcat  LIKE LINE OF it_prjcat,
ld_docvr  TYPE DRAW-DOKVR ,
it_stdcat  TYPE STANDARD TABLE OF CSCSTD ,
wa_stdcat  LIKE LINE OF it_stdcat,
ld_postp  TYPE RC29L-POSTP ,
it_tplcat  TYPE STANDARD TABLE OF CSCTPL ,
wa_tplcat  LIKE LINE OF it_tplcat,
ld_retcode_only  TYPE CSDATA-XFELD ,
ld_stlan  TYPE RC29L-STLAN ,
ld_werks  TYPE RC29L-WERKS ,
ld_stltp  TYPE RC29A-ATABR ,
ld_newsi  TYPE CSDATA-XFELD .


ld_datub = 20210129

"populate fields of struture and append to itab
append wa_wultb to it_wultb.

ld_datuv = 20210129

"populate fields of struture and append to itab
append wa_doccat to it_doccat.

SELECT single DOKAR
FROM DRAW
INTO ld_docar.


"populate fields of struture and append to itab
append wa_equicat to it_equicat.

SELECT single DOKNR
FROM DRAW
INTO ld_docnr.


"populate fields of struture and append to itab
append wa_kndcat to it_kndcat.

"populate fields of struture and append to itab
append wa_matcat to it_matcat.

SELECT single DOKTL
FROM DRAW
INTO ld_doctl.


"populate fields of struture and append to itab
append wa_prjcat to it_prjcat.

SELECT single DOKVR
FROM DRAW
INTO ld_docvr.


"populate fields of struture and append to itab
append wa_stdcat to it_stdcat.

ld_postp = some text here

"populate fields of struture and append to itab
append wa_tplcat to it_tplcat.

ld_retcode_only = some text here

ld_stlan = some text here

ld_werks = some text here

ld_stltp = some text here

ld_newsi = some text here

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name CS_WHERE_USED_DOC or its description.