question on program logic using SKC1A
Account - Using SAKNR and selected company code (BUKRS) get alternative account using table SKB1
Description - To be obtained from SKA1 using account number found above in chart of accounts CEFR
Carry-forward debit - UMSAV
Debit period from 1 to n - ii=01 to pp UMiiS
Credit period from 1 to n - ii=01 to pp UMiiH
In order to obtain this text file, an ABAP program should be written. The extraction program should use structure SKC1A to obtain data and use the following selections:
BUKRS : Company code
SAKNR : no selection
GJAHR : Fiscal Year
GSBER : no selection
CURTP : 10 (can be hardcoded and displayed)
HWAER : EUR (can be hard-coded and displayed)
Period : pp (from 01 to special period 13)
I wrote the program using the function 'FOR_ALL_SKC1A'. I have attached it below.
after the final specs came from the user, this following line was included
An example of the use of this structure can be found in program RFSSLD00
I looked at the program RFSSLD00 and it's logic is nowhere near mine. It uses a statement GET SKC1A. after looking at this program,
I am not I have the program coded correctly based on the specs.
can somebody let me know if I am doing this correctly or if I need to mirror my program after the RFSSLD00.
*& Report ZFI_FR_ETAFI
skat. "G/L Account Master Record (Chart of Accounts: Description)
TYPES: BEGIN OF ty_skat,
saknr TYPE skat-saknr, "Account Number
txt50 TYPE skat-txt50, "account Description
END OF ty_skat.
data: begin of itab occurs 0,
filler1(5) TYPE C,
account(6) TYPE C,
filler2(4) TYPE C,
description(35) TYPE c,
filler3(39) TYPE c,
carryfwdamt(21) TYPE c,
filler4(70) TYPE c,
totdeb(18) TYPE c,
filler5(63) TYPE c,
totcred(18) TYPE c,
end of itab.
data: iskc1a TYPE TABLE of skc1a with header line.
data: it_skat TYPE STANDARD TABLE OF ty_skat with header line.
data: w_totcred like skc1a-um01s.
data: w_totdeb like skc1a-um01s.
data: w_cramount like skc1a-um01s.
data: w_dbamount like skc1a-um01s.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_ktopl TYPE skat-ktopl OBLIGATORY,
p_bukrs TYPE skb1-bukrs OBLIGATORY,
p_year TYPE payr-gjahr OBLIGATORY,
p_poper TYPE bkpf-monat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
SELECT saknr txt50
FROM skat INTO TABLE it_skat
WHERE ktopl = p_ktopl.
loop at it_skat.
CLEAR iskc1a. REFRESH iskc1a.
call function 'FOR_ALL_SKC1A'
xbukrs = p_bukrs
xsaknr = it_skat-saknr
xskc1a = iskc1a
key_incomplete = 1
not_authorized = 2
not_found = 3.
loop at iskc1a.
if iskc1a-gjahr = p_year.
w_cramount = 0.
w_dbamount = 0.
w_totcred = 0.
w_totdeb = 0.
do p_poper times
varying w_cramount from iskc1a-um01s next iskc1a-um02s.
w_totcred = w_totcred + w_cramount.
do p_poper times
varying w_dbamount from iskc1a-um01h next iskc1a-um02h.
w_totdeb = w_totdeb + w_dbamount.
if it_skat-saknr(4) = '0000'.
itab-account = it_skat-saknr+4.
itab-account = it_skat-saknr.
itab-description = it_skat-txt50.
itab-carryfwdamt = iskc1a-umsav.
shift itab-carryfwdamt right deleting trailing space.
itab-totdeb = w_totdeb.
shift itab-totdeb right deleting trailing space.
itab-totcred = w_totcred.
shift itab-totcred right deleting trailing space.
if itab-carryfwdamt <> 0 or
itab-totdeb <> 0 or
itab-totcred <> 0.
call function 'GUI_DOWNLOAD'
filename = 'C:\ETAFI.txt'
data_tab = itab
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.
write: / ' process unsuccessful'.
write: / 'process successful'.
Rich Heilman replied
That program uses a logical database to get the data. This is why it looks different. Don't worry, as long as you can verify the data against something else, you can do it the way that you are. Personally, I never use logical databases.