Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Not able to upload Characteristic Values in BAPI_DOCUMENT_CREATE2

Former Member
0 Likes
3,872

Hello Experts,

I have a requirement where i am uploading documents using BAPI_DOCUMENT_CREATE2.

Here I have to upload Characteristics value which is there in tcode CV01N > Additional Tab. Following are the fields i need to update in transaction CV01N:

1. Department Name

2. Drawing Type

3. Region Name

4. Sub Station

5. Voltage Rating

6. Current Rating

7. Fault Current Value     

For this i am trying to pass value in BAPI_CHARACTERISTIC_VALUES structure . But not able to achive the result.

BAPI_CHARACTERISTIC_VALUES-CHARVALUE = wa_data-atwrt_Dept.
append BAPI_CHARACTERISTIC_VALUES.

Please guide me on this.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
2,588

Hi Prachi ,

Pass these two parameter values for Classification in above BAPI.

CHARACTERISTICVALUES

CLASSALLOCATIONS

Like ..

DATA : S_CHARA   LIKE BAPI_CHARACTERISTIC_VALUES    OCCURS 0 WITH HEADER LINE,

           S_CLASSA  LIKE BAPI_CLASS_ALLOCATION             OCCURS 0 WITH HEADER LINE .

    

S_CHARA-CLASSTYPE =   '017'  .                             " Pass Class Type   this sample data

S_CHARA-CLASSNAME = ' PROE_ELECTRIC'   .        " Class Name

S_CHARA-CHARNAME  = 'Capacitance' .                 " Characteristics Name

S_CHARA-CHARVALUE = '   abc '     .                      " Characteristics Value

 

APPEND S_CHARA.

Same as in  S_CLASSA for Respective field's Value .

S_CLASSA- CLASSTYPE =   '    '

S_CLASSA- CLASSNAME =   '     '

S_CLASSA- STATUS         =   '   '

S_CLASSA- STANDARDCLASS  =  '   '

APPEND S_CLASSA .

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

   EXPORTING

     DOCUMENTDATA               =

..................................................................

.................................................................

TABLES

    CHARACTERISTICVALUES       =    S_CHARA

    CLASSALLOCATIONS                =  S_CLASSA .

call BAPI_TRANSACTION_COMMIT .

Regard's

Smruti

Hello Experts,

I have a requirement where i am uploading documents using BAPI_DOCUMENT_CREATE2.

Here I have to upload Characteristics value which is there in tcode CV01N > Additional Tab. Following are the fields i need to update in transaction CV01N:

1. Department Name

2. Drawing Type

3. Region Name

4. Sub Station

5. Voltage Rating

6. Current Rating

7. Fault Current Value     

For this i am trying to pass value in BAPI_CHARACTERISTIC_VALUES structure . But not able to achive the result.

BAPI_CHARACTERISTIC_VALUES-CHARVALUE = wa_data-atwrt_Dept.
append BAPI_CHARACTERISTIC_VALUES.

Please guide me on this.

Thanks.

6 REPLIES 6
Read only

Former Member
0 Likes
2,588

Hi,

Please refer the FM Documentation and see whether you are passing all the parameters correctly.

FU BAPI_DOCUMENT_CREATE2

____________________________________________________

Short Text

Dokument anlegen

Functionality

You can use this function module to create documents and all data that belongs to it.
You can create a document info record with the following data:

  • Langauge dependent short and long texts
  • Any number of originals
  • Object links

  You can also check in the original application files into the SAP database, vault, or archive. 

  • Classification characteristics
  • Document structures; can be created using table DocumentStructure.

  The objects of engineering change management (DOC_BOM_CHANGE_NUMBER DOC_BOM_VALID_FROM  oder DOC_BOM_REVISON_LEVEL) relate only to the processing of the document structure. If no additional information for the change object is given, the items in the table document structure apply as the new status of the structure for the current date........... Restrictions: The document key fields are equally keys for the BOM items, which means that a document may not be used for several items. 

Restrictions:

  • Additional files supported only as interface parameters COMPONENTS for future development.
  • Valuations of object links are not supported.

Example

 

**..... Document data

DATA: ls_doc    LIKE bapi_doc_draw2.

**..... Bapi-Returnstruktur

      ls_return LIKE bapiret2.

**.... Key feilds of the document

DATA: lf_doctype    LIKE bapi_doc_draw2-documenttype,

      lf_docnumber  LIKE bapi_doc_draw2-documentnumber,

      lf_docpart    LIKE bapi_doc_draw2-documenttype,

      lf_docversion LIKE bapi_doc_draw2-documenttype.

**.... Originals that are checked in simultaneously

DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,

**.... Short texts

      lt_drat  LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,

**.... Object links

      lt_drad  LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.

**----------------------------------------------------------------------

** Allcoate document data

ls_doc-documenttype    = 'DRW'.

ls_doc-documentnumber  = '4711'.

ls_doc-documentversion = '00'.

ls_doc-documentpart    = '000'.

ls_doc-statusextern   = 'AF'.

ls_doc-laboratory     = '001'. 


** Check in original 1 simultaneously in the SAP Database
REFRESH lt_files.
CLEAR lt_files.

lt_files-storagecategory = 'SAP-SYSTEM'.
lt_files-docfile      = 'c:\temp\drawing.txt'.
lt_wsapplication = 'TXT'.
APPEND lt_files.

lt_files-storagecategory = 'VAULT'.
lt_files-docfile      = 'c:\temp\drawing.dwg'.
lt_wsapplication = 'DWG'.
APPEND lt_files.

lt_files-storagecategory = 'SAP-SYSTEM'.
lt_files-docfile      = 'c:\temp\drawing.ppt'.
lt_wsapplication = 'PPT'.
APPEND lt_files.

** Short texts
CLEAR lt_drat.
REFRESH lt_drat.

** German short text
lt_drat-language    = 'DE'.
lt_drat-description = 'Getriebe'.
APPEND lt_drat.

** English short text
lt_drat-language    = 'EN'.
lt_drat-description = 'gear'.
APPEND lt_drat.

** Object link to material master
CLEAR lt_drad.
REFRESH lt_drad.
lt_drad-objecttype = 'MARA'.
lt_drad-objectkey  = 'M4711'.
APPEND lt_drad.

* ---------------------------------------------------------------------
* Create document
* ---------------------------------------------------------------------
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
      EXPORTING: documentdata         = ls_doc
      IMPORTING: documenttype         = lf_doctype
                 documentnumber       = lf_docnumber
                 documentpart         = lf_docpart
                 documentversion      = lf_docversion
                 return               = ls_return
     TABLES: documentdescriptions = lt_drat
             objectlinks          = lt_drad
             documentfiles        = lt_files.

** Did an error occur ??
  IF ls_return-type CA 'EA'.
    ROLLBACK WORK.
    MESSAGE ID '26' TYPE 'I' NUMBER '000'
            WITH ls_return-message.

  ELSE.
    COMMIT WORK.
  ENDIF.

Notes

You can insert the following data in addition to document data:

  • Object links
  • Classifications and characteristic valuation
  • Language dependent document descriptions
  • Long text documents
  • Document structure
  • Originals

Regards,

Amit

Read only

Former Member
2,589

Hi Prachi ,

Pass these two parameter values for Classification in above BAPI.

CHARACTERISTICVALUES

CLASSALLOCATIONS

Like ..

DATA : S_CHARA   LIKE BAPI_CHARACTERISTIC_VALUES    OCCURS 0 WITH HEADER LINE,

           S_CLASSA  LIKE BAPI_CLASS_ALLOCATION             OCCURS 0 WITH HEADER LINE .

    

S_CHARA-CLASSTYPE =   '017'  .                             " Pass Class Type   this sample data

S_CHARA-CLASSNAME = ' PROE_ELECTRIC'   .        " Class Name

S_CHARA-CHARNAME  = 'Capacitance' .                 " Characteristics Name

S_CHARA-CHARVALUE = '   abc '     .                      " Characteristics Value

 

APPEND S_CHARA.

Same as in  S_CLASSA for Respective field's Value .

S_CLASSA- CLASSTYPE =   '    '

S_CLASSA- CLASSNAME =   '     '

S_CLASSA- STATUS         =   '   '

S_CLASSA- STANDARDCLASS  =  '   '

APPEND S_CLASSA .

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

   EXPORTING

     DOCUMENTDATA               =

..................................................................

.................................................................

TABLES

    CHARACTERISTICVALUES       =    S_CHARA

    CLASSALLOCATIONS                =  S_CLASSA .

call BAPI_TRANSACTION_COMMIT .

Regard's

Smruti

Read only

0 Likes
2,588

Thanks to all. It worked.

Read only

Former Member
0 Likes
2,588

Hi All,

I am trying to update class chararestics using BAPI_DOCUMENT_CREAT2. Document is getting generated but the class characteristics are not getting update in the document.

I have passed the below parameters.

*- Class type-017

      ls_charvalues-classtype          = lc_017.

*- Class name-DIR_REG_CLASS

      ls_charvalues-classname          = lc_dir_reg_class.

      APPEND ls_charvalues TO t_charvalues.

      CLEAR  ls_charvalues.

*- Reg model

      IF NOT <ls_final>-reg_model IS INITIAL.

        ls_charvalues-charname         = lc_reg_model.

        ls_charvalues-charvalue        = <ls_final>-reg_model.

        APPEND ls_charvalues TO t_charvalues.

        CLEAR  ls_charvalues.

      ENDIF.

*- Class allocation classtype

      ls_classalloc-classtype     = lc_017.

*- Class allocation classname

      ls_classalloc-classname     = lc_dir_reg_class.

**- Class allocation status

*      ls_classalloc-status        = lc_1.

**- Class allocation standard class

*      ls_classalloc-standardclass = 'X'.

      APPEND ls_classalloc TO t_classalloc.

      CLEAR  ls_classalloc.

*- Original type

      ls_docfiles-originaltype    = lc_1.

*- Storage category

      ls_docfiles-storagecategory = lc_zemc_hrc.

*- Application

      ls_docfiles-wsapplication   = <ls_final>-att_type.

*- Original of the document

      ls_docfiles-docfile         = <ls_final>-file_path.

      ls_docfiles-CHECKEDIN       = 'X'.

  CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

      EXPORTING

        documentdata         = iv_documentdata

        pf_http_dest         = lc_saphttpa

        pf_ftp_dest          = 'SAPFTPA'

        defaultclass         = 'X'

      IMPORTING

        DOCUMENTTYPE         = ev_documenttype

        documentnumber       = ev_documentnumber

        DOCUMENTPART         = ev_documentpart

        DOCUMENTVERSION      = ev_documentversion

        return               = ev_return

      TABLES

        characteristicvalues = t_charvalues

        classallocations     = t_classalloc

*       DOCUMENTDESCRIPTIONS =

        objectlinks          = t_objectlinks

*       DOCUMENTSTRUCTURE    =

        documentfiles        = t_docfiles.

I am getting the below error.

Class type 017, object type DRAW, object ZRG000000000000001000000005500000

Please guide me what parameters to be passed to resolve this error.

Thanks,

Praveen

Read only

Former Member
0 Likes
2,588

Hi All,

I have a small question on DMS.

While creating the document via FM ‘BAPI_DOCUMENT_CREATE2’ its goes into error “document category and documetn discpline required, we have customize the DMS as these two are always to be put as manadtory , how to handle this in progrm.

Please suggest.

Thanks & Regards,

Raj Singh

Read only

0 Likes
2,156

I'm having the same problem.
Did you found a solution for this please?