SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_CLASS_CHANGE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1637

PostPosted: Sat May 10, 2008 7:44 pm    Post subject: BAPI_CLASS_CHANGE Reply with quote

BAPI_CLASS_CHANGE - Change Class

Code:
*get old template data
CALL FUNCTION 'BAPI_CLASS_GETDETAIL'
EXPORTING
classtype = gc_class_type
classnum = iv_profile_template_id
*LANGUISO =
languint = space
KEYDATE = SY-DATUM
IMPORTING
classbasicdata = ls_classbasicdata_old
*CLASSDOCUMENT =
*CLASSADDITIONAL =
*CLASSSTANDARD =
return = ls_return
TABLES
classdescriptions = lt_classdescriptions_old
classlongtexts = lt_classlongtexts_old
classcharacteristics = lt_charact.
*CLASSCHARVALUES =

*check whether an error occurred
IF ls_return-type = gc_e.
  APPEND ls_return TO et_return.
  EXIT.
ENDIF.

*transfer old characteristics
LOOP AT lt_charact INTO ls_charact.
  ls_characteristics_old-name_char = ls_charact-name_char.
  ls_characteristics_old-code_letter = ls_charact-name_char.
  ls_characteristics_old-charact_origin = ls_charact-charact_origin.
  ls_characteristics_old-department_view = ls_charact-department_view.
  APPEND ls_characteristics_old TO lt_characteristics_old.
ENDLOOP.

*transfer new characteristics
REFRESH lt_classcharacteristics.
CLEAR ls_classcharacteristics.
LOOP AT it_charactname INTO ls_charactname.
  ls_classcharacteristics-name_char = ls_charactname-charact_name.
  APPEND ls_classcharacteristics TO lt_classcharacteristics.
ENDLOOP.

*transfer template description
REFRESH lt_classdescriptions.
CLEAR ls_classdescriptions.
IF it_classdescriptions[] IS INITIAL.
  ls_classdescriptions-langu = sy-langu.
  ls_classdescriptions-catchword = iv_profile_template_descr.
  INSERT ls_classdescriptions INTO TABLE lt_classdescriptions.
ELSE.
  lt_classdescriptions = it_classdescriptions.
ENDIF.

REFRESH lt_classlongtexts.
READ TABLE lt_classlongtexts_old INTO ls_classlongtexts INDEX 1.
ls_classlongtexts-text_descr = is_classbasicdata-katalog.
CLEAR is_classbasicdata-katalog.

IF sy-subrc NE 0.
IF is_classbasicdata-local_class = 'X'.
  ls_classlongtexts-text_type = '01'.
ELSEIF is_classbasicdata-local_class = 'N'.
  ls_classlongtexts-text_type = '02'.
ELSE.
  ls_classlongtexts-text_type = '00'.
ENDIF.
  ls_classlongtexts-langu = sy-langu.
ENDIF.
APPEND ls_classlongtexts TO lt_classlongtexts.

*change profile template
CALL FUNCTION 'BAPI_CLASS_CHANGE'
EXPORTING
classnum = iv_profile_template_id
classtype = gc_class_type
keydate = sy-datum
classbasicdata = ls_classbasicdata_old
classbasicdatanew = is_classbasicdata
TABLES
return = et_return
classdescriptions = lt_classdescriptions_old
classcharacteristics = lt_characteristics_old
*CHARACTERISTICOVERWRITE =
classlongtexts = lt_classlongtexts
classdescriptionsnew = lt_classdescriptions
classcharacteristicsnew = lt_classcharacteristics
CHARACTERISTICOVERWRITENEW =
classlongtextsnew = lt_classlongtexts.

*check whether an error occurred
READ TABLE et_return TRANSPORTING NO FIELDS WITH KEY
type = gc_e.
CHECK sy-subrc 0.

*commit if necessary
CHECK iv_xcommit space.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.


Now see the table klah ur class will be created.
Run this program

Code:
TABLES: klah.

DATA : WA_BAPICLASSKEY TYPE BAPI_CLASS_KEY,
       WA_BAPI1003BASIC TYPE BAPI1003_BASIC,
       WA_BAPI1003BASICNEW TYPE BAPI1003_BASIC_NEW,
       WA_BAPICATCH TYPE BAPI1003_CATCH,
       IT_BAPICATCH LIKE TABLE OF  BAPI1003_CATCH,
       WA_BAPICHARACT TYPE BAPI1003_CHARACT,
       IT_BAPICHARACT LIKE TABLE OF BAPI1003_CHARACT,
       WA_BAPICATCHNEW TYPE BAPI1003_CATCH_NEW,
       IT_BAPICATCHNEW LIKE TABLE OF  BAPI1003_CATCH_NEW,
       WA_BAPICHARACTOVR TYPE BAPI1003_CHARACT_OVERWR,
       IT_BAPICHARACTOVR LIKE TABLE OF BAPI1003_CHARACT_OVERWR,
       WA_BAPICHARACTOVRVALUE TYPE BAPI1003_CHARACT_VALUE_OVR,
       IT_BAPICHARACTOVRVALUE LIKE TABLE OF BAPI1003_CHARACT_VALUE_OVR,
       WA_BAPICHARVALTEXT TYPE BAPI1003_CHARVALTEXT,
       IT_BAPICHARVALTEXT LIKE TABLE OF BAPI1003_CHARVALTEXT.

 WA_BAPICLASSKEY-CLASSNUM = 'C_BIKE7'.
 WA_BAPICLASSKEY-CLASSTYPE = 300.
 WA_BAPI1003BASIC-STATUS = '2'.
 WA_BAPI1003BASIC-valid_to = '31.12.9999'.
 WA_BAPI1003BASIC-valid_from = sy-datum.
 WA_BAPI1003BASICNEW-STATUS = '2'.
 WA_BAPI1003BASICNEW-valid_to = '31.12.9999'.
 WA_BAPI1003BASICNEW-valid_from = sy-datum.

 WA_BAPICATCH-langu = 'EN'.
 WA_BAPICATCH-CATCHWORD = 'Bike Description'.
 append WA_BAPICATCH to it_BAPICATCH.

  WA_BAPICHARACt-NAME_CHAR = 'ZVC_MOTOR'.
 APPEND  WA_BAPICHARACT TO  IT_BAPICHARACT.

 WA_BAPICATCHNEW-langu = 'EN'.
 WA_BAPICATCHNEW-CATCHWORD = 'Bike Description'.
 append WA_BAPICATCHNEW to it_BAPICATCHNEW.

 WA_BAPICHARACTOVR-NAME_CHAR = 'ZVC_MOTOR'.
 APPEND WA_BAPICHARACTOVR TO IT_BAPICHARACTOVR.

 WA_BAPICHARACTOVRVALUE-NAME_CHAR = 'ZVC_MOTOR'.
 WA_BAPICHARACTOVRVALUE-CHAR_VALUE = 'STANDARD'.
 APPEND WA_BAPICHARACTOVRVALUE TO IT_BAPICHARACTOVRVALUE.

 WA_BAPICHARVALTEXT-CHARACT = 'ZVC_MOTOR'.
 WA_BAPICHARVALTEXT-VALUE = 'STANDARD'.
 WA_BAPICHARVALTEXT-VALDESCR = 'STANDARD BIKE'.
 WA_BAPICHARVALTEXT-LANGU = 'EN'.
 APPEND WA_BAPICHARVALTEXT TO IT_BAPICHARVALTEXT.

CALL FUNCTION 'BAPI_CLASS_CHANGE'
  EXPORTING
    CLASSNUM                            = WA_BAPICLASSKEY-CLASSNUM
    CLASSTYPE                           = WA_BAPICLASSKEY-CLASSTYPE

*CHANGENUMBER                        = CHANGENUMBER
*KEYDATE                             = SY-DATUM

    CLASSBASICDATA                      = WA_BAPI1003BASIC
    CLASSBASICDATANEW                   = WA_BAPI1003BASICNEW

*CLASSDOCUMENT                       = CLASSDOCUMENT
*CLASSDOCUMENTNEW                    = CLASSDOCUMENTNEW
*CLASSADDITIONAL                     = CLASSADDITIONAL
*CLASSADDITIONALNEW                  = CLASSADDITIONALNEW
*CLASSSTANDARD                       = CLASSSTANDARD
*CLASSSTANDARDNEW                    = CLASSSTANDARDNEW

  TABLES
    RETURN                              = IT_BAPIRETURN
    CLASSDESCRIPTIONS                   = it_BAPICATCH

*CLASSLONGTEXTS                      = CLASSLONGTEXTS

   CLASSCHARACTERISTICS                = IT_BAPICHARACT
   CHARACTERISTICOVERWRITE             = IT_BAPICHARACTOVR
   CHARACTVALUEOVERWRIT                = IT_BAPICHARACTOVRVALUE

*CHARACTERISTICVALUETEXTOVR          = CHARACTERISTICVALUETEXTOVR

    CLASSDESCRIPTIONSNEW                = it_BAPICATCHNEW

*CLASSLONGTEXTSNEW                   = CLASSLONGTEXTSNEW
*CLASSCHARACTERISTICSNEW             = CLASSCHARACTERISTICSNEW
*CHARACTERISTICOVERWRITENEW          = CHARACTERISTICOVERWRITENEW
*CHARACTVALUEOVERWRITNEW             = CHARACTVALUEOVERWRITNEW

   CHARACTERISTICVALUETEXTOVRNEW       = IT_BAPICHARVALTEXT.

CALL FUNCTION 'BAPI_CLASS_CREATE'
  EXPORTING
    CLASSNUMNEW                 = WA_BAPICLASSKEY-CLASSNUM
    CLASSTYPENEW                = WA_BAPICLASSKEY-CLASSTYPE

*CHANGENUMBER                = CHANGENUMBER

    CLASSBASICDATA              = WA_BAPI1003BASIC

*CLASSDOCUMENT               = CLASSDOCUMENT
*CLASSADDITIONAL             = CLASSADDITIONAL
*CLASSSTANDARD               = CLASSSTANDARD

  TABLES
    RETURN                      = IT_BAPIRETURN
    CLASSDESCRIPTIONS           = it_BAPICATCH

*CLASSLONGTEXTS              = CLASSLONGTEXTS

   CLASSCHARACTERISTICS        = IT_BAPICHARACT
   CHARACTOVERWRITE            = IT_BAPICHARACTOVR
   CHARACTVALUEOVERWRITE       = IT_BAPICHARACTOVRVALUE
   CHARACTVALUETEXTOVR         = IT_BAPICHARVALTEXT.
          .

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
   I_STRUCTURE_NAME                  = 'BAPIRET2'
  TABLES
    T_OUTTAB                          = IT_BAPIRETURN.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.