SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_GL_GETGLACCPERIODBALANCES



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> FI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sun Oct 14, 2007 8:41 pm    Post subject: BAPI_GL_GETGLACCPERIODBALANCES Reply with quote

Code:

*&---------------------------------------------------------------------*
*& Report ZRAGHU13
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZRAGHU13.
TYPE-POOLS : slis.

TABLES: bkpf,bseg,bsis.


TYPES:BEGIN OF ty_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
gjahr TYPE bkpf-gjahr,
blart TYPE bkpf-blart,
monat TYPE bkpf-monat,
budat TYPE bkpf-budat,
hkont TYPE bsis-hkont,

END OF ty_bkpf.

TYPES:BEGIN OF ty_output,
bukrs TYPE bkpf-bukrs,
gjahr TYPE bkpf-gjahr,
openbal TYPE bseg-dmbtr,
dttrns TYPE bseg-dmbtr,
* dttrns TYPE bseg-SHKZG,
crtrans TYPE bseg-dmbtr,
* crtrans type bseg-shkzg,
clbal TYPE bseg-dmbtr,

END OF ty_output.



DATA : fcat TYPE slis_t_fieldcat_alv,
lcat TYPE slis_fieldcat_alv,
layout TYPE slis_layout_alv,
fcath TYPE slis_t_add_fieldcat,
lcath TYPE slis_add_fieldcat.
DATA : lt_list_top_of_page TYPE slis_t_listheader.
DATA : cpos TYPE i.





DATA:it_bkpf TYPE STANDARD TABLE OF ty_bkpf,
wa_bkpf TYPE ty_bkpf.

DATA:it_output TYPE STANDARD TABLE OF ty_output,
wa_output TYPE ty_output.



DATA:it_balnce LIKE STANDARD TABLE OF bapi1028_4,
wa_balnce LIKE bapi1028_4.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS:pr_bukrs TYPE bkpf-bukrs DEFAULT '1000' OBLIGATORY ,
pr_gjahr TYPE bkpf-gjahr OBLIGATORY .
SELECT-OPTIONS:so_monat FOR bkpf-monat OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.


START-OF-SELECTION.

DEFINE field_cat.
add 1 to cpos.
clear lcat.
lcat-col_pos = cpos.
lcat-tabname = &1.
lcat-fieldname = &2.
lcat-seltext_m = &3.
lcat-no_out = &4.
append lcat to fcat.
END-OF-DEFINITION.



*get data.

PERFORM f001_get_data.


END-OF-SELECTION.
*display data.

PERFORM f002_diplay_data.



*&---------------------------------------------------------------------*

*& Form f001_get_data
*&---------------------------------------------------------------------*

* text
*----------------------------------------------------------------------*

* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*

FORM f001_get_data .

DATA :tabix LIKE sy-tabix,
w_bal type n.

*GET BELNR.
CLEAR:it_bkpf.
SELECT bukrs belnr gjahr blart monat budat
INTO TABLE it_bkpf
FROM bkpf
WHERE bukrs EQ pr_bukrs
AND gjahr EQ pr_gjahr
AND monat IN so_monat.



LOOP AT it_bkpf INTO wa_bkpf .

CLEAR:it_balnce.
CALL FUNCTION 'BAPI_GL_GETGLACCPERIODBALANCES'
EXPORTING
companycode = wa_bkpf-bukrs
glacct = '0000113100'
fiscalyear = wa_bkpf-gjahr
currencytype = '10'
* IMPORTING
* BALANCE_CARRIED_FORWARD =
* RETURN =
TABLES
account_balances = it_balnce .


ENDLOOP.

sort it_balnce[] by comp_code.

LOOP AT it_balnce INTO wa_balnce where FIS_PERIOD le so_monat-low.


CLEAR:wa_output,w_bal.


w_bal = wa_balnce-balance.
wa_output-bukrs = wa_balnce-comp_code.
wa_output-gjahr = wa_balnce-fisc_year.
wa_output-openbal = wa_balnce-balance + w_bal.
wa_output-dttrns = wa_balnce-debits_per.
wa_output-crtrans = wa_balnce-credit_per.
wa_output-clbal = ( wa_balnce-balance + wa_balnce-debits_per
- wa_balnce-credit_per ).

APPEND wa_output TO it_output.

ENDLOOP.


ENDFORM. " f001_get_data
*&---------------------------------------------------------------------*

*& Form f002_diplay_data
*&---------------------------------------------------------------------*

* text
*----------------------------------------------------------------------*

* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*

FORM f002_diplay_data .



DATA: cprog LIKE sy-repid VALUE sy-repid.
REFRESH fcat.




field_cat 'IT_OUTPUT' 'BUKRS' 'Company Code' ' '.
field_cat 'IT_OUTPUT' 'GJAHR' 'Fiscal Year' ' '.

field_cat 'IT_OUTPUT' 'OPENBAL' 'Open Balance' ' '.
field_cat 'IT_OUTPUT' 'DTTRNS' 'Debit Transactions' ' '.
field_cat 'IT_OUTPUT' 'CTTRANS' 'Credit Transactions' ' '.
field_cat 'IT_OUTPUT' 'CLBAL' 'Closing Balnace' ' '.

layout-zebra = 'X'.
layout-colwidth_optimize = 'X'.
layout-get_selinfos = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = cprog
i_callback_top_of_page = 'TOP_OF_PAGE'
* i_grid_title = 'Unrestricted Stock'
is_layout = layout
it_fieldcat = fcat
i_default = 'X'
i_save = 'A'
* is_variant = w_variant
TABLES
t_outtab = IT_OUTPUT
EXCEPTIONS
program_error = 1
OTHERS = 2.


ENDFORM. " f002_diplay_data

*&---------------------------------------------------------------------*

*& Form top_of_page
*&---------------------------------------------------------------------*

* text
*----------------------------------------------------------------------*

FORM top_of_page.

DATA: l_line TYPE slis_listheader.
DATA: lw_usr21 TYPE usr21.
DATA: lw_name TYPE v_addr_usr-name_text.
*
l_line-typ = 'H'.
l_line-info = text-001.
APPEND l_line TO lt_list_top_of_page.

l_line-typ = 'S'.
l_line-key = text-005.
l_line-info = sy-title.
APPEND l_line TO lt_list_top_of_page.

l_line-typ = 'S'.
l_line-key = 'Company Code :'.
l_line-info = pr_bukrs.
APPEND l_line TO lt_list_top_of_page.

l_line-typ = 'S'.
l_line-key = text-006.
l_line-info = 'Fiscal Year' .
APPEND l_line TO lt_list_top_of_page.

l_line-typ = 'S'.
l_line-key = text-007.
WRITE sy-datum TO l_line-info.
l_line-info+11(1) = '/'.
WRITE sy-uzeit TO l_line-info+13.
APPEND l_line TO lt_list_top_of_page.



CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lt_list_top_of_page.

ENDFORM. "top_of_page


PS: Credit and Debit is based on the field BSEG-SHKZG (Debit/Credit Indicator). Bust this is commented in ur program.
Make use of this field and go ahead.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> FI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.