Skip to Content
0
Former Member
Mar 03, 2013 at 08:28 AM

how to create BDC with transaction FB10

45 Views

Hi guys

please help me.

My requirement is :

I have to fetch data from bsis table with fields BUKRS, BELNR, GJAHR, ZUONR BUZEI, HKONT . Next i have to fetch data from bkpf table with fields bktxt, tcode accordingly bsis table with select single. If found update valus of tcode and bktxt. Store the values in final table.

If tcode = 'F110' fetch data from regup table with fields laufd, laufi, xvorl, zbukr, vblnr lifnr with select single. If values are found update of zuonr in final table after deleting leading zeros of lifnr..

If tcode <> 'F110' fetch data from bseg table with fields BUKRS,BELNR,GJAHR lifnr with select single. If values founf update zuonr in final table after deleting leading zeros of lifnr.

I have develop following code but it is not complete. Please tell me my logic is going correct or not. And if not please give me solution

&---------------------------------------------------------------------*

*& Report ZREPORT

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT zreport.

TYPE-POOLS : slis.

TYPES : BEGIN OF t_bsis,

bukrs TYPE bsis-bukrs,

zuonr TYPE bsis-zuonr,

gjahr TYPE bsis-gjahr,

belnr TYPE bsis-belnr,

buzei TYPE bsis-buzei,

hkont TYPE bsis-hkont,

END OF t_bsis,

BEGIN OF t_bkpf,

bukrs TYPE bkpf-bukrs,

belnr TYPE bkpf-belnr,

gjahr TYPE bkpf-gjahr,

tcode TYPE bkpf-tcode,

bktxt TYPE bkpf-bktxt,

END OF t_bkpf,

BEGIN OF t_regup,

laufd TYPE regup-laufd,

laufi TYPE regup-laufi,

xvorl TYPE regup-xvorl,

zbukr TYPE regup-zbukr,

lifnr TYPE regup-lifnr,

vblnr TYPE regup-vblnr,

END OF t_regup,

BEGIN OF t_bseg,

lifnr TYPE bseg-lifnr,

bukrs TYPE bseg-bukrs,

belnr TYPE bseg-belnr,

gjahr TYPE bseg-gjahr,

END OF t_bseg.

TYPES :BEGIN OF i_date,

i_date TYPE d,

END OF i_date.

TYPES : BEGIN OF e_date,

e_date TYPE dats,

END OF e_date.

TYPES : BEGIN OF bkpf_final,

bukrs TYPE bsis-bukrs,

belnr TYPE bsis-belnr,

gjahr TYPE bsis-gjahr,

zuonr TYPE bsis-zuonr,

hkont TYPE bsis-hkont,

buzei TYPE bsis-buzei,

tcode TYPE bkpf-tcode,

bktxt TYPE bkpf-bktxt,

id(6) TYPE c,

e_date TYPE dats,

laufd TYPE regup-laufd,

laufi TYPE regup-laufi,

xvorl TYPE regup-xvorl,

zbukr TYPE regup-zbukr,

lifnr TYPE regup-lifnr,

vblnr TYPE regup-vblnr,

zuonr TYPE bsis-zuonr,

tcode TYPE bkpf-tcode,

END OF bkpf_final.

DATA : it_bsis TYPE STANDARD TABLE OF t_bsis,

it_bkpf TYPE STANDARD TABLE OF t_bkpf,

it_regup TYPE STANDARD TABLE OF t_regup,

it_bseg TYPE STANDARD TABLE OF t_bseg,

it_bkpf_final TYPE STANDARD TABLE OF bkpf_final,

it_final TYPE STANDARD TABLE OF t_final.

DATA : wa_it_bsis LIKE LINE OF it_bsis,

wa_it_bkpf LIKE LINE OF it_bkpf,

wa_it_regup LIKE LINE OF it_regup,

wa_it_bseg LIKE LINE OF it_bseg,

wa_it_bkpf_final LIKE LINE OF it_bkpf_final,

wa_it_final LIKE LINE OF it_final.

DATA : hkont TYPE bsis-hkont,

dzuonr TYPE bsis-zuonr.

DATA : int_date TYPE STANDARD TABLE OF i_date,

wa_int_date LIKE LINE OF int_date.

DATA : ext_date TYPE STANDARD TABLE OF e_date,

wa_ext_date LIKE LINE OF ext_date.

TYPES : BEGIN OF t_id,

id(6) TYPE c,

END OF t_id.

DATA : it_id TYPE STANDARD TABLE OF t_id,

wa_it_id LIKE LINE OF it_id.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_hkont FOR hkont,

s_zuonr FOR dzuonr.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

SELECT bukrs zuonr gjahr belnr buzei hkont

FROM bsis

INTO TABLE it_bsis

WHERE hkont IN s_hkont AND

zuonr IN s_zuonr.

IF it_bsis[] IS NOT INITIAL.

SELECT bukrs belnr gjahr tcode bktxt

FROM bkpf

INTO TABLE it_bkpf

FOR ALL ENTRIES IN it_bsis

WHERE bukrs = it_bsis-bukrs AND

belnr = it_bsis-belnr AND

gjahr = it_bsis-gjahr.

LOOP AT it_bsis INTO wa_it_bsis.

wa_it_bkpf_final-bukrs = wa_it_bsis-bukrs.

wa_it_bkpf_final-zuonr = wa_it_bsis-zuonr.

wa_it_bkpf_final-gjahr = wa_it_bsis-gjahr.

wa_it_bkpf_final-belnr = wa_it_bsis-belnr.

wa_it_bkpf_final-buzei = wa_it_bsis-buzei.

wa_it_bkpf_final-hkont = wa_it_bsis-hkont.

READ TABLE it_bkpf INTO wa_it_bkpf WITH KEY bukrs = wa_it_bsis-bukrs

belnr = wa_it_bsis-belnr

gjahr = wa_it_bsis-gjahr BINARY SEARCH.

SPLIT wa_it_bkpf-bktxt AT ' ' INTO wa_int_date-i_date wa_it_id-id.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

date_internal = wa_int_date-i_date "sy-datum

IMPORTING

date_external = wa_ext_date-e_date

EXCEPTIONS

date_internal_is_invalid = 1

OTHERS = 2.

IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.

wa_it_bkpf_final-e_date = wa_ext_date-e_date.

wa_it_bkpf_final-id = wa_it_id-id.

wa_it_bkpf_final-tcode = wa_it_bkpf-tcode.

wa_it_bkpf_final-bktxt = wa_it_bkpf-bktxt.

LOOP AT it_bkpf_final INTO wa_it_bkpf_final.

CASE wa_it_bkpf-tcode.

WHEN 'F110'.

SELECT SINGLE laufd laufi xvorl zbukr lifnr vblnr

FROM regup

INTO wa_it_regup

* FOR ALL ENTRIES IN it_bkpf_final

WHERE laufd = wa_it_bkpf_final-e_date AND

laufi = wa_it_bkpf_final-id AND

zbukr = wa_it_bkpf_final-bukrs AND

vblnr = wa_it_bkpf_final-belnr AND

xvorl = ' '." AND

* lifnr = no-zero.

SHIFT wa_it_regup-lifnr LEFT DELETING LEADING '0'.

* wa_it_bkpf_final-laufd = wa_it_bkpf_final-laufd.

* wa_it_bkpf_final-laufi = wa_it_bkpf_final-laufi.

* wa_it_bkpf_final-zbukr = wa_it_bkpf_final-zbukr.

* wa_it_bkpf_final-vblnr = wa_it_bkpf_final-vblnr.

* wa_it_bkpf_final-xvorl = wa_it_bkpf_final-xvorl.

* wa_it_bkpf_final-lifnr = wa_it_bkpf_final-lifnr.

WHEN OTHERS.

SELECT SINGLE bukrs belnr gjahr lifnr

FROM bseg

INTO wa_it_bseg

WHERE bukrs = wa_it_bkpf_final-bukrs AND

belnr = wa_it_bkpf_final-belnr AND

gjahr = wa_it_bkpf_final-gjahr.

SHIFT wa_it_bseg-lifnr LEFT DELETING LEADING '0'.

wa_it_bkpf_final-bukr = wa_it_bkpf_final-bukr.

wa_it_bkpf_final-vblnr = wa_it_bkpf_final-vblnr.

wa_it_bkpf_final-xvorl = wa_it_bkpf_final-xvorl.

wa_it_bkpf_final-gjahr = wa_it_bkpf_final-gjahr.

wa_it_bkpf_final-lifnr = wa_it_bkpf_final-lifnr.

ENDIF.

ENDCASE.

APPEND wa_it_bkpf_final TO it_bkpf_final.

CLEAR wa_ext_date.

CLEAR wa_it_id.

CLEAR wa_it_bkpf_final.

ENDLOOP.

*ENDLOOP.

* ENDIF.

ENDIF.

IF wa_it_bkpf_final-zuonr[] IS INITIAL.

DELETE wa_it_bkpf_final.

ENDIF.

END-OF-SELECTION.

now i want to use BDC with transaction FB10 for fields to update ZUONR

  1. BUKRS, BELNR, GJAHR, BUZEI, HKONT,
  2. ZUONR

which i dont have any idea how to do that.

Please help me.