*----------------------------------------------------------------------* * DECLARATIONS * *----------------------------------------------------------------------* TABLES: bkpf. TYPES: BEGIN OF ty_bkpf, bukrs TYPE bukrs, belnr TYPE belnr_d, gjahr TYPE gjahr, blart TYPE blart, bldat TYPE bldat, budat TYPE budat, bktxt TYPE bktxt, END OF ty_bkpf. DATA BEGIN OF gt_zvim OCCURS 0. INCLUDE STRUCTURE zvim_wf_det_blkv. DATA END OF gt_zvim. DATA: gt_bkpf TYPE STANDARD TABLE OF ty_bkpf, gs_bkpf LIKE LINE OF gt_bkpf, gt_options TYPE TABLE OF rfc_db_opt, gt_fields TYPE TABLE OF rfc_db_fld, gt_data TYPE TABLE OF tab512, gs_options TYPE rfc_db_opt, gs_fields TYPE rfc_db_fld, gs_data TYPE tab512. FIELD-SYMBOLS <gf_field> TYPE any. *----------------------------------------------------------------------* * LAYOUT * *----------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: so_bukrs FOR bkpf-bukrs, so_belnr FOR bkpf-belnr, so_blart FOR bkpf-blart, so_bldat FOR bkpf-bldat, so_budat FOR bkpf-budat. SELECTION-SCREEN END OF BLOCK b1. *----------------------------------------------------------------------* * PROGRAM BODY * *----------------------------------------------------------------------* START-OF-SELECTION. SELECT bukrs belnr gjahr blart bldat budat bktxt FROM bkpf INTO CORRESPONDING FIELDS OF TABLE gt_bkpf WHERE bukrs IN so_bukrs AND belnr IN so_belnr AND blart IN so_blart AND bldat IN so_bldat AND budat IN so_budat. LOOP AT gt_bkpf INTO gs_bkpf. CLEAR gt_options[]. CONCATENATE 'BUKRS = ''' gs_bkpf-bukrs '''' INTO gs_options-text. APPEND gs_options TO gt_options. CONCATENATE 'AND BELNR = ''' gs_bkpf-bktxt(10) '''' INTO gs_options-text. APPEND gs_options TO gt_options. CONCATENATE 'AND GJAHR = ''' gs_bkpf-gjahr '''' INTO gs_options-text. APPEND gs_options TO gt_options. CALL FUNCTION 'RFC_READ_TABLE' DESTINATION 'FIP400' EXPORTING query_table = 'ZVIM_WF_DET_BLKV' TABLES options = gt_options fields = gt_fields data = gt_data EXCEPTIONS table_not_available = 1 table_without_data = 2 option_not_valid = 3 field_not_valid = 4 not_authorized = 5 data_buffer_exceeded = 6 OTHERS = 7. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. LOOP AT gt_data INTO gs_data. LOOP AT gt_fields INTO gs_fields. IF gs_fields-fieldname = 'BELNR'. gt_zvim-belnr = gs_bkpf-belnr. ELSE. ASSIGN COMPONENT gs_fields-fieldname OF STRUCTURE gt_zvim TO <gf_field>. <gf_field> = gs_data+gs_fields-offset(gs_fields-length). ENDIF. ENDLOOP. APPEND gt_zvim. ENDLOOP. INSERT zvim_wf_det_blkv FROM TABLE gt_zvim. CLEAR: gt_data[], gt_zvim[]. ENDLOOP. END-OF-SELECTION. EXIT. *----------------------------------------------------------------------*
venerdì 11 novembre 2016
Lettura via RFC di una tabella tramite FM standard
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento