‎2006 Feb 14 7:54 AM
Hi,
i want to know the logic for writing a program in which it reads the invoice numbers from a flat file and checks for its accounting document status. if the status is "cleared" then it should record that invoice no. in another flat file.
the main part is i want to know is that whats tables are to be used and what fields and the relation between those tables.
regards,
maqsood
‎2006 Feb 14 8:18 AM
‎2006 Feb 14 8:04 AM
HI
what you have to do is
use GUI_UPLOAD to load the data from the flat file to the internal table.
then use the table vbrk,vbrp,vbuk for billing documents win which VBUK is the status. vbeln->documetn number
tehn use GUI_download to write to the flat file
code:
tables vbrp,vbuk,bseg,bsad.
<b>data: i_belnr like bseg-belnr.
data: begin of record occurs 0.
vbeln like vbrp-vbeln.
end of record.
data: begin of rec_confirmed occurs 0.
vbeln like vbrp-vbeln.----
>invoice number
belnr like bsad-belnr.----
>billing document
augdt like bsad-augdt. -
> cleared date
augbl like bsad-augbl .----
>clearing document
end of record.</b>
data: i_vbuk like vbuk occurs 0.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'D:\Personal\invoice.txt'
FILETYPE = 'DAT'
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 = RECORD
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.
<b>loop at record.
select belnr into i_belnr from BSEG where vbeln = record-vbeln.
selecting the closed items
select belnr augdt augbl into i_bsad from BSAD where belnr = i_belnr.
if sy-subrc eq 0.
loop at i_bsad.
rec_confirmed-vbeln = record-vbeln.
rec-confirmet-belnr = i_bsad-belnr.
rec-confirmet-augdt = i_bsad-augdt.
rec-confirmet-augdl = i_bsad-augdl.
append rec_confirmed.
endloop.
endif.
******************similarly you can collect the open *****items from BSID
endloop.</b>
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = <file name>
FILETYPE = 'DAT'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = rec_confirmed
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
regards
kishore
replay if you want more
Message was edited by: Harikishore Sreenivasulu
Message was edited by: Harikishore Sreenivasulu
‎2006 Feb 14 8:18 AM
‎2006 Feb 14 9:14 AM
Hi Kishore,
thanx for ur quick reply.
I think it is not picking up from vbuk.
i want to know from hwre its picking in vf03 t-code.
when we enter invoice no. and then see the documentation flow.
as i have hundereds of invoice numbers i can not run this t-code again and angain so i want to right a program which will find the invoice no.'s which r having the document status as clearned
is there anything to do with these tables like BSIS OR BSIK
WAITING FOR UR REPLY
REGARDS,
MAQSOOD
‎2006 Feb 14 10:11 AM
HI maqsood
actually you have to link VBRP-vbeln(sales document number or invoice number) with bseg-vbeln(sales document number) and get the bseg-belnr(Billing document number) .
then use the tables BSAD and BSID.
BSAD->Closed items.
BSID->opened items.
if the belnr is present in BSAD you have the cleared date
the document is present in BSID then the document is not cleared.
<b>I have made the changes. this logic might work. notify me if there is a change</b>
regards
kishore
‎2006 Feb 14 10:40 AM
Hi Kishore,
I think ur on the right path.
but when i try to execute ur logic through se16 its taking long time to respond i think we have to enter the other key fields also inorder to execute it fast as this query i have to run on a stand by production server.
And by the way i have to record the uncleared invoice no. not the cleared one.
sorry i gave wrong info before.
regards,
maqsood
‎2006 Feb 14 10:54 AM
hi,
just check out this logic.
in BKPF table enter these values
AWTYPE: VBRK
AWKEY: invoice no.
to get the BELNR field value.
enter the BLENR field value in BSID table .
here i need to know the values for other key fields so that accessing will be fast.
i have the company code field value and how to find the rest of the key fields values
regards,
maqsood
‎2006 Feb 14 11:09 AM
Hi
ya, BSEG will take more amount time bcoz it is the biggest table in sap.
Ya your logic will be faster. You can get the customer number KUNNR from vbrk and BLART document type as 'RV'->sales document
regards
kishore
‎2006 Feb 14 11:27 AM
‎2006 Feb 14 11:27 AM
HI
In vf03 vbdkr->header view for billing
adn vbdpr-.item view for billing is used.
you will most of the values in that view.
you can get the Customer number in the BSID as i said earlier from the Bill-to-party in the view vbdkr.
regards
kishore
‎2006 Feb 14 11:31 AM
HI
BSIS & BSAS are the open items & closed items for the General ledger which contians not only the sales data it contains all the Bills which is very complicated.
whereas
BSAD & BSID is for Customer bills i.e sales
BSIK & BSAK is for vendor bills i.e purchasing
regards
kishore
‎2006 Feb 15 8:24 AM
‎2006 Feb 16 12:44 PM
Hi kishore,
i have send my report to my seniors and was waiting for their replies.
Any ways thanx a lot guys.
i will close this tread now.
regards,
maqsood
‎2006 Feb 14 6:40 PM
‎2006 Feb 15 5:30 AM
Hi Maqsood
what happened? Is your problem solved?
If yes please close the thread.
regards
kishore