Skip to Content
0
Former Member
Aug 02, 2008 at 07:53 AM

bdc for f-02 compairing posting key

128 Views

hi all,

i want do the uploading the data through bdc using f-02.

but problem is that with posting key = 39 and posting key = 40.

line item for 39 is vary or not fix and that all 39 having one 40.In that posting key = 40 i want the amount sum of in that is in 39

the recording and excel file given below:-

report ZFI_F02

no standard page heading line-size 255.

include bdcrecx1.

DATA : FNAME TYPE STRING.

DATA : FILENAME TYPE STRING.

DATA : BEGIN OF IT_OUT OCCURS 0,

BLDAT(10) TYPE C,

BLART LIKE BKPF-BLART,

BUKRS LIKE BKPF-BUKRS,

BUDAT(10) TYPE C,

MONAT LIKE BKPF-MONAT,

WAERS LIKE BKPF-WAERS,

XBLNR LIKE BKPF-XBLNR,

  • KURSF LIKE BKPF-KURSF,

newbs LIKE RF05A-NEWBS,

NEWKO LIKE RF05A-NEWKO,

NEWUM LIKE RF05A-NEWUM,

  • NEWBW LIKE RF05A-NEWBW,

*

  • NEWUM1 LIKE RF05A-NEWUM,

  • NEWBW1 LIKE RF05A-NEWBW,

WRBTR TYPE string,

  • BSEG-WRBTR,

BUPLA like BSEG-BUPLA,

SECCO like BSEG-SECCO,

ZFBDT(10) TYPE C,

SGTXT LIKE BSEG-SGTXT,

NEWBS1 LIKE RF05A-NEWBS,

NEWKO1 LIKE RF05A-NEWKO,

WRBTR1 TYPE string,

  • ZUONR LIKE BSEG-ZUONR,

KOSTL LIKE COBL-KOSTL,

*

  • ZUONR1 LIKE BSEG-ZUONR,

  • SGTXT1 LIKE BSEG-SGTXT,

  • KOSTL1 LIKE COBL-KOSTL,

END OF IT_OUT .

*DATA: IT_OUT1 LIKE IT_OUT OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN : BEGIN OF BLOCK ABC WITH FRAME TITLE TEXT-T01.

PARAMETER : file LIKE IBIPPARMS-PATH OBLIGATORY.

SELECTION-SCREEN : END OF BLOCK ABC.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = 'FILE'

IMPORTING

FILE_NAME = FILE

.

start-of-selection.

FNAME = FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FNAME

FILETYPE = 'DAT'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = IT_OUT

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*IT_OUT1[] = IT_OUT[].

perform open_group.

LOOP AT IT_OUT.

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWUM'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BKPF-BLDAT'

IT_OUT-BLDAT.

perform bdc_field using 'BKPF-BLART'

IT_OUT-BLART.

perform bdc_field using 'BKPF-BUKRS'

IT_OUT-BUKRS.

perform bdc_field using 'BKPF-BUDAT'

IT_OUT-BUDAT.

perform bdc_field using 'BKPF-MONAT'

IT_OUT-MONAT.

perform bdc_field using 'BKPF-WAERS'

IT_OUT-WAERS.

perform bdc_field using 'BKPF-XBLNR'

IT_OUT-XBLNR.

perform bdc_field using 'FS006-DOCID'

'*'.

*LOOP AT IT_OUT1 WHERE poskey = '39'.

perform bdc_field using 'RF05A-NEWBS'

IT_OUT-NEWBS.

perform bdc_field using 'RF05A-NEWKO'

IT_OUT-NEWKO.

perform bdc_field using 'RF05A-NEWUM'

IT_OUT-NEWUM.

perform bdc_dynpro using 'SAPMF05A' '0304'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

IT_OUT-WRBTR.

perform bdc_field using 'BSEG-BUPLA'

IT_OUT-BUPLA.

perform bdc_field using 'BSEG-SECCO'

IT_OUT-SECCO.

perform bdc_field using 'BSEG-ZFBDT'

IT_OUT-ZFBDT.

perform bdc_field using 'BSEG-SGTXT'

IT_OUT-SGTXT.

*LOOP AT IT_OUT1 WHERE poskey = '40'.

perform bdc_field using 'RF05A-NEWBS'

IT_OUT-NEWBS1.

perform bdc_field using 'RF05A-NEWKO'

IT_OUT-NEWKO1.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-SGTXT'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

IT_OUT-WRBTR1.

perform bdc_field using 'DKACB-FMORE'

'X'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-KOSTL'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-KOSTL'

IT_OUT-KOSTL.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-WRBTR'.

perform bdc_field using 'BDC_OKCODE'

'=BS'.

perform bdc_field using 'BSEG-WRBTR'

'500.00'.

perform bdc_field using 'DKACB-FMORE'

'X'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-GSBER'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-KOSTL'

'9300'.

perform bdc_field using 'COBL-PRCTR'

'SERVICE'.

perform bdc_dynpro using 'SAPMF05A' '0700'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWBS'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_transaction using 'F-02'.

*ENDLOOP.

ENDLOOP.

perform close_group.

and the data will be :-

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10268 Y 3,000.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10555 Y 500.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 40 131113060 3,500.00 1000 1000 30.06.2008 JUNE 08 SAL JV 9750

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10035 E 4,800.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10037 E 9,500.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10048 E 4,000.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10051 E 3,540.80 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10053 E 4,500.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10062 E 4,500.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10068 E 4,000.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10092 E 1,000.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10109 E 4,900.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10123 E 4,900.00 1000 1000 30.06.2008 JUNE 08 SAL JV

30.06.2008 JV 1000 30.06.2008 1 INR JUNE 08 SAL JV 39 10213 E 4,900.00 1000 1000 30.06.2008 JUNE 08 SAL JV