Skip to Content
0
Former Member
Apr 21, 2008 at 11:22 AM

BDC Problem

47 Views

Hi All,

My problem is not solved earlier that was related to Invoice Date and LR Date..

Now i m sending my Code..plz check it and clear me that where can i insert my condition for date comparision..

CODE...

********

********

REPORT ZSD06_TEST

NO STANDARD PAGE HEADING LINE-SIZE 255 MESSAGE-ID ZBDC.

TABLES : T100,

BKPF,

LIKP,

NASE.

DATA: L_MSTRING(480).

RANGES SELTAB FOR VBRK-VBELN.

RANGES SEL_RG_KSCHL FOR NASE-KSCHL.

RANGES RG_VBELN FOR VBRK-VBELN.

RANGES RG_KSCHL FOR NASE-KSCHL.

DATA: PM_VERMO LIKE NASE-VERMO.

DATA: BEGIN OF BDCDATA OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF BDCDATA.

DATA: BEGIN OF ITAB OCCURS 0,

VBELN LIKE LIKP-VBELN,

BOLNR LIKE LIKP-BOLNR,

BELNR LIKE RF05L-BELNR,

GJAHR LIKE RF05L-GJAHR,

ZFBDT(10) TYPE C,

END OF ITAB.

DATA : INVOICE_DATE TYPE D .

DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

DATA LD_ANSWER.

CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'

EXPORTING

DEFAULTOPTION = 'N'

TEXTLINE1 = 'BDC to enter LR.NO & DATE in delivery,accounting doc.'

TEXTLINE2 = 'Do you want to continue ?'

TITEL = SY-TITLE

  • START_COLUMN = 25

  • START_ROW = 6

CANCEL_DISPLAY = ' '

IMPORTING

ANSWER = LD_ANSWER

EXCEPTIONS

OTHERS = 0.

IF LD_ANSWER NE 'J'.

MESSAGE S001.

LEAVE PROGRAM.

ENDIF.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\LRDETAIL.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = ITAB

  • 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.

LOOP AT ITAB.

CONCATENATE '00' ITAB-VBELN INTO ITAB-VBELN.

SELECT SINGLE * FROM LIKP WHERE VBELN = ITAB-VBELN.

****

****

SELECT FKDAT FROM VBRK INTO INVOICE_DATE WHERE VBELN = ITAB-VBELN.

ENDSELECT.

IF ITAB-ZFBDT LT INVOICE_DATE.

****

****

IF SY-SUBRC <> 0.

MESSTAB-TCODE = 'VL02N'.MESSTAB-DYNAME = 'SAPMV50A'.MESSTAB-DYNUMB = '4004'.

MESSTAB-MSGTYP = 'E'. MESSTAB-MSGSPRA = 'E'.MESSTAB-MSGID = 'VL'.

MESSTAB-MSGNR = '302'. MESSTAB-MSGV1 = ITAB-VBELN. MESSTAB-MSGV2 = ''.

MESSTAB-MSGV3 = ''. MESSTAB-ENV = 'CTU'. MESSTAB-FLDNAME = 'LIKP-VBELN'.

APPEND MESSTAB.

ELSE.

PERFORM BDC_DYNPRO USING 'SAPMV50A' '4004'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'LIKP-VBELN'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.

PERFORM BDC_FIELD USING 'LIKP-VBELN' ITAB-VBELN.

PERFORM BDC_DYNPRO USING 'SAPMV50A' '1000'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=HTRA_T'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'LIPS-MATNR(02)'.

PERFORM BDC_DYNPRO USING 'SAPMV50A' '2000'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=SICH_T'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'LIKP-BOLNR'.

PERFORM BDC_FIELD USING 'LIKP-BOLNR' ITAB-BOLNR.

CALL TRANSACTION 'VL02N' USING BDCDATA MODE 'A' MESSAGES INTO MESSTAB.

REFRESH BDCDATA.

ENDIF.

***

IF ITAB-BELNR <> ' '.

SELECT SINGLE * FROM BKPF WHERE BELNR = ITAB-BELNR

AND GJAHR = ITAB-GJAHR.

IF SY-SUBRC = 0.

MESSTAB-TCODE = 'FB02'.MESSTAB-DYNAME = 'SAPMF05L'.MESSTAB-DYNUMB = '0100'.

MESSTAB-MSGTYP = 'E'. MESSTAB-MSGSPRA = 'E'.MESSTAB-MSGID = 'F5'.

MESSTAB-MSGNR = '238'. MESSTAB-MSGV1 = ITAB-BELNR. MESSTAB-MSGV2 = '1000'.

MESSTAB-MSGV3 = ITAB-GJAHR. MESSTAB-ENV = 'CTU'. MESSTAB-FLDNAME = 'RF05L-BELNR'.

APPEND MESSTAB.

ELSE.

PERFORM BDC_DYNPRO USING 'SAPMF05L' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RF05L-BELNR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '/00'.

PERFORM BDC_FIELD USING 'RF05L-BELNR' ITAB-BELNR.

PERFORM BDC_FIELD USING 'RF05L-BUKRS' '1000'.

PERFORM BDC_FIELD USING 'RF05L-GJAHR' ITAB-GJAHR.

PERFORM BDC_DYNPRO USING 'SAPMF05L' '0700'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RF05L-ANZDT(01)'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=PK'.

PERFORM BDC_DYNPRO USING 'SAPMF05L' '0301'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'BSEG-ZFBDT'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=AE'.

PERFORM BDC_FIELD USING 'BSEG-ZFBDT' ITAB-ZFBDT.

CALL TRANSACTION 'FB02' USING BDCDATA MODE 'A' MESSAGES INTO MESSTAB.

***

REFRESH BDCDATA.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

DATA: SPOOLID TYPE TSP01-RQIDENT. " Spool ID no.

NEW-PAGE PRINT ON

DESTINATION 'LOCL'

IMMEDIATELY ''

NO DIALOG.

LOOP AT MESSTAB WHERE MSGTYP EQ 'E'.

SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA

AND ARBGB = MESSTAB-MSGID

AND MSGNR = MESSTAB-MSGNR.

IF SY-SUBRC = 0.

L_MSTRING = T100-TEXT.

IF L_MSTRING CS '&1'.

REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ELSE.

REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ENDIF.

CONDENSE L_MSTRING.

WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).

ELSE.

WRITE: / MESSTAB.

ENDIF.

IF MESSTAB-TCODE EQ 'FB02'.

DELETE ITAB WHERE BELNR = MESSTAB-MSGV1.

ENDIF.

ENDLOOP.

LOOP AT ITAB WHERE BELNR <> ' '.

SELTAB-SIGN = 'I'.

SELTAB-OPTION = 'EQ'.

SELTAB-LOW = ITAB-BELNR.

APPEND SELTAB.

ENDLOOP.

DESCRIBE TABLE SELTAB LINES SY-TABIX.

IF SY-TABIX IS INITIAL.

WRITE 'NO DATA EXIST for output(VF31)'.

ELSE.

SEL_RG_KSCHL-LOW = 'ZD00'.

APPEND SEL_RG_KSCHL.

SUBMIT SD70AV3A

WITH RG_VBELN IN SELTAB

WITH RG_KSCHL IN SEL_RG_KSCHL

WITH PM_VERMO EQ '2'

AND RETURN.

ENDIF.

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM. "BDC_DYNPRO

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDFORM. "BDC_FIELD

**************************************************************************************************************************************************

Note:- In this code, where is bold, there i change for comparision date...

In my Problem..I want that LR Date must not be Previous to Invoice Date (means if Invoice date is 15.04.2008, then LR Date should not taken previously, only accepted after 15.04.2008)..If we insert LR Date more than Invoice date,then it should be taken..

Thanks..