‎2006 Apr 04 9:07 PM
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
*&
&----
REPORT ZFI_FR_ETAFI.
*----
TABLES
*----
TABLES:
skat. "G/L Account Master Record (Chart of Accounts: Description)
*----
TYPES
*----
TYPES: BEGIN OF ty_skat,
saknr TYPE skat-saknr, "Account Number
txt50 TYPE skat-txt50, "account Description
END OF ty_skat.
*----
DATA
*----
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.
*SELECT-OPTIONS:
----
PARAMETERS *
----
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.
----
*START-OF-SELECTION *
----
START-OF-SELECTION.
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'
exporting
xbukrs = p_bukrs
xsaknr = it_skat-saknr
tables
xskc1a = iskc1a
exceptions
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.
enddo.
do p_poper times
varying w_dbamount from iskc1a-um01h next iskc1a-um02h.
w_totdeb = w_totdeb + w_dbamount.
enddo.
if it_skat-saknr(4) = '0000'.
itab-account = it_skat-saknr+4.
else.
itab-account = it_skat-saknr.
endif.
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.
append itab.
endif.
endif.
endloop.
endloop.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:\ETAFI.txt'
tables
data_tab = itab
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.
write: / ' process unsuccessful'.
ELSE.
write: / 'process successful'.
ENDIF.
----
*END-OF-SELECTION *
----
‎2006 Apr 04 9:24 PM
‎2006 Apr 04 9:23 PM
I wouldn't change the program based on the suggestion. The important thing is - does it work the way it's supposed to. If you think it does, show it to the person who gave you the specs. He or she'll let you know if there's a problem.
Rob
‎2006 Apr 04 9:24 PM