*----------------------------------------------------------------------* * DECLARATIONS * *----------------------------------------------------------------------* DATA: BEGIN OF gt_in OCCURS 0, matnr LIKE MARA-MATNR, [...] END OF gt_in. DATA: gt_bdcdata LIKE BDCDATA OCCURS 0 WITH HEADER LINE. DATA: gv_qid LIKE APQI-QID. *----------------------------------------------------------------------* * LAYOUT * *----------------------------------------------------------------------* PARAMETERS: pa_sess(12) NO-DISPLAY. *---------------------------------------------------------------------* * FORM CREA_SESSIONE * *---------------------------------------------------------------------* FORM crea_sessione. CLEAR: gt_bdcdata, gt_bdcdata[]. PERFORM bdc_open_group USING pa_sess. LOOP AT gt_in. PERFORM bdc_dynpro_field USING: 'X' 'ZMMA_MATIMB2' '0100', ' ' 'BDC_OKCODE' '=ENTR', ' ' 'L_DYN_0100-MATNR' gt_in-matnr. [...] PERFORM bdc_transaction USING 'ZMMA_MATIMB'. CLEAR: gt_bdcdata, gt_bdcdata[]. ENDLOOP. PERFORM bdc_close_group. PERFORM bdc_start_group USING pa_sess. ENDFORM. "crea_sessione *----------------------------------------------------------------------* * FORM BDC_OPEN_GROUP * *----------------------------------------------------------------------* FORM bdc_open_group USING p_session. CALL FUNCTION 'BDC_OPEN_GROUP' EXPORTING CLIENT = SY-MANDT GROUP = p_session KEEP = 'X' USER = SY-UNAME IMPORTING QID = gv_qid. IF SY-SUBRC <> 0. MESSAGE E000(YA1) WITH 'ERRORE BDC_OPEN_GROUP PER ' 'SESSIONE BATCH-INPUT ' p_session. ENDIF. ENDFORM. "bdc_open_group *----------------------------------------------------------------------* * FORM BDC_CLOSE_GROUP * *----------------------------------------------------------------------* FORM bdc_close_group. CALL FUNCTION 'BDC_CLOSE_GROUP' EXCEPTIONS NOT_OPEN = 1 QUEUE_ERROR = 2 OTHERS = 3. IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. "bdc_close_group *----------------------------------------------------------------------* * FORM BDC_DYNPRO_FIELD * *----------------------------------------------------------------------* FORM bdc_dynpro_field USING p_dynbegin p_fnam p_fval. CLEAR gt_bdcdata. IF p_dynbegin = 'X'. gt_bdcdata-program = p_fnam. gt_bdcdata-dynpro = p_fval. gt_bdcdata-dynbegin = 'X'. ELSE. gt_bdcdata-fnam = p_fnam. gt_bdcdata-fval = p_fval. ENDIF. APPEND gt_bdcdata. ENDFORM. "bdc_dynpro_field *----------------------------------------------------------------------* * FORM BDC_TRANSACTION * *----------------------------------------------------------------------* FORM bdc_transaction USING p_tcode. CALL FUNCTION 'BDC_INSERT' EXPORTING TCODE = p_tcode TABLES DYNPROTAB = gt_bdcdata. ENDFORM. "bdc_transaction *----------------------------------------------------------------------* * FORM BDC_START_GROUP * *----------------------------------------------------------------------* FORM bdc_start_group USING p_session. DATA: lv_bdc(4) VALUE 'BDC ', "Datatyp = Batch-Input lv_amodus(1) VALUE 'E', "Visualizzare errore lv_lmodus(1), "Registro ampliato lv_expert(1), "Sess. esperto lv_defsize(1), "Dim. standard dynpro lv_errfend(1), "Interr. in caso di err. log lv_simubatch(1). "Simulare sess. background CALL 'BDC_START_GROUP' ID 'GROUP' FIELD p_session ID 'QUID' FIELD gv_qid ID 'DISPLAY' FIELD lv_amodus ID 'LOG' FIELD lv_lmodus ID 'EXPERT' FIELD lv_expert ID 'DYSIZE' FIELD lv_defsize ID 'ERRORFORCEEND' FIELD lv_errfend ID 'SIMUBATCH' FIELD lv_simubatch. ENDFORM. "bdc_start_group *----------------------------------------------------------------------*
lunedì 27 aprile 2015
Inserimento e lancio di una sessione Batch-Input
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento