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

Batch classification update



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Mon Oct 08, 2007 4:57 pm    Post subject: Batch classification update Reply with quote

Check this below pgm..it works fine from 3.1I to 4.6D...it uses MSC2 t-code for batch classification update..

before running this program make sure that characteristics of a class or not mandatory using CL03 and CT04 transactions..

but as per requirement uploading the qlty results to classification can be done using batch input..

change the screen sequence as required for ur requirement

Code:
REPORT z_bca.

*---------------------------------------------------------------------*
* Checkbox p_list to turn on/off the printing of *
* the already classified batches. This limits the report from *
* hundreds of pages to just one or so. *
*---------------------------------------------------------------------*
* If the same material/plant with different batch already exists then*
* the record is saved without updating screen 500. *
*---------------------------------------------------------------------*

TABLES:
mcha,
inob.

*--------------------------------------------------------------------*
* Select Option & Parameters *
*--------------------------------------------------------------------*
SELECTION-SCREEN : BEGIN OF BLOCK a WITH FRAME TITLE text-001.
PARAMETERS : p_werks LIKE mcha-werks OBLIGATORY,

p_class LIKE rmclf-class OBLIGATORY,

p_list(1) DEFAULT ' '.
SELECTION-SCREEN SKIP.
PARAMETERS : p_bigci LIKE bgr00-group OBLIGATORY
DEFAULT 'ZMSC2'.


SELECTION-SCREEN : END OF BLOCK a.

*--------------------------------------------------------------------*
* Data *
*--------------------------------------------------------------------*
DATA : w_buffer(50) TYPE c.
DATA : w_last_buffer(50) TYPE c.
DATA : cpt TYPE n.
DATA : coche(1) TYPE c.
DATA : n_coche(1) TYPE c.
DATA: BEGIN OF itab_articles OCCURS 0,
matnr(1 TYPE c,
werks(4) TYPE c,
charg(10) TYPE c,
herkl(3) TYPE c,
sister(1) TYPE c,
END OF itab_articles.

DATA : BEGIN OF itab_bdc OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA : END OF itab_bdc.
DATA: w_errors(1).
DATA: w_sister(1).
*--------------------------------------------------------------------*
SELECT * FROM mcha WHERE werks EQ p_werks
AND lvorm EQ space.

CONCATENATE mcha-matnr mcha-werks mcha-charg INTO w_buffer.

SELECT * FROM inob WHERE klart EQ '022' AND
obtab EQ 'MCHA' AND
objek EQ w_buffer.
ENDSELECT.

IF sy-subrc NE 0.
IF p_list = 'X'.
WRITE : / 'A classifier ', 20 mcha-matnr, w_buffer.
ULINE.
ENDIF.

w_errors = 'X'.
w_sister = 'Y'.

CONCATENATE mcha-matnr mcha-werks '%' INTO w_buffer.

IF w_buffer <> w_last_buffer.
SELECT * FROM inob WHERE klart EQ '022' AND
obtab EQ 'MCHA' AND
objek LIKE w_buffer.
ENDSELECT.
IF sy-subrc <> 0.
w_sister = 'N'.
ENDIF.
ENDIF.

w_last_buffer = w_buffer.

CLEAR itab_articles.

MOVE mcha-matnr TO itab_articles-matnr.
MOVE mcha-werks TO itab_articles-werks.
MOVE mcha-charg TO itab_articles-charg.

IF mcha-herkl = 'EX '.
MOVE ' ' TO itab_articles-herkl.
ELSE.
MOVE mcha-herkl TO itab_articles-herkl.
ENDIF.
MOVE w_sister TO itab_articles-sister.

APPEND itab_articles.

ELSE.
IF p_list = 'X'.
WRITE : / 'Classified ', 20 mcha-matnr, w_buffer.
ULINE.
ENDIF.
ENDIF.

CLEAR w_buffer.
ENDSELECT.

IF w_errors <> 'X'.
SKIP 1.
WRITE: / 'No batches to classify'.
ENDIF.

*--------------------------------------------------------------------*
* Initial record of the BI *
*--------------------------------------------------------------------*
IF NOT itab_articles[] IS INITIAL.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = p_bigci
keep = 'X'
user = sy-uname
EXCEPTIONS
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 10
OTHERS = 11.
ENDIF.


MOVE 'x' TO coche.
CLEAR n_coche.

LOOP AT itab_articles.

WRITE : / 'A classifier',20 itab_articles-matnr,'/'.
WRITE : itab_articles-werks, '/', itab_articles-charg,'/'.

PERFORM bdc_dynpro USING :
'X' 'SAPMM03S' '0105',
' ' 'RM03S-MATNR' itab_articles-matnr,
' ' 'RM03S-WERKS' itab_articles-werks,
' ' 'RM03S-CHARG' itab_articles-charg,
' ' 'BDC_OKCODE' '/00',

'X' 'SAPMM03S' '0200',
' ' 'RM03S-CHKLJ' coche,
' ' 'RM03S-CHKLN' n_coche,
' ' 'MCHA-HERKL' itab_articles-herkl.

IF itab_articles-sister = 'N'.
PERFORM bdc_dynpro USING :
' ' 'BDC_OKCODE' 'CLAS',

'X' 'SAPLCLFM' '0500',
' ' 'RMCLF-CLASS(01)' p_class,
' ' 'RMCLF-STATU(01)' '1',
' ' 'BDC_OKCODE' 'ENDE',
'X' 'SAPMM03S' '0200'.
ENDIF.

PERFORM bdc_dynpro USING :
' ' 'BDC_OKCODE' 'BU'.

CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'MSC2'
TABLES
dynprotab = itab_bdc
EXCEPTIONS
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 6
OTHERS = 7.
*
CLEAR itab_bdc.
REFRESH itab_bdc.

ENDLOOP.

IF NOT itab_articles[] IS INITIAL.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
ENDIF.
*-----------------------------------------------------------------------
* Form BDC_DYNPRO
*-----------------------------------------------------------------------
FORM bdc_dynpro USING dynbegin champ valeur.
IF dynbegin ='X'.
CLEAR itab_bdc.
itab_bdc-program = champ.
itab_bdc-dynpro = valeur.
itab_bdc-dynbegin = 'X'.
APPEND itab_bdc.
ELSE.
CLEAR itab_bdc.
itab_bdc-fnam = champ.
itab_bdc-fval = valeur.
itab_bdc-dynbegin = ' '.
APPEND itab_bdc.
ENDIF.
ENDFORM. " BDC_DYNPRO
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 -> ММ 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 cannot 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.