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

Report Cleared Customer Documents



 
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: 1640

PostPosted: Sat Oct 06, 2007 10:56 pm    Post subject: Report Cleared Customer Documents Reply with quote

Code:
REPORT zfirp001 .

TYPE-POOLS: slis.

TABLES: bsak.

SELECT-OPTIONS: s_bukrs FOR bsak-bukrs,
s_lifnr FOR bsak-lifnr,
s_blart FOR bsak-blart,
s_augdt FOR bsak-augdt,
s_zterm FOR bsak-zterm.

PARAMETERS: s_list AS CHECKBOX,
s_vari LIKE disvariant-variant.

DATA: g_ext_num(24) TYPE c.

DATA: BEGIN OF gt_bsak OCCURS 0,
bukrs LIKE bsak-bukrs,
lifnr LIKE bsak-lifnr,
augdt LIKE bsak-augdt,
gjahr LIKE bsak-gjahr,
belnr LIKE bsak-belnr,
blart LIKE bsak-blart,
zterm LIKE bsak-zterm,
END OF gt_bsak.

DATA: BEGIN OF gt_bseg OCCURS 0,
bukrs LIKE bseg-bukrs,
belnr LIKE bseg-belnr,
gjahr LIKE bseg-gjahr,
wrbtr LIKE bseg-wrbtr,
projk LIKE bseg-projk,
shkzg LIKE bseg-shkzg,
hkont LIKE bseg-hkont,
END OF gt_bseg.

* ALV
DATA: gt_fieldtab TYPE slis_t_fieldcat_alv,
g_save(1) TYPE c,
g_variant LIKE disvariant.



DATA: BEGIN OF gt_result OCCURS 0,
bukrs LIKE bsak-bukrs,
lifnr LIKE bsak-lifnr,
name1 LIKE lfa1-name1,
augdt LIKE bsak-augdt,
gjahr LIKE bsak-gjahr,
belnr LIKE bsak-belnr,
blart LIKE bsak-blart,
zterm LIKE bsak-zterm,
wrbtr LIKE bseg-wrbtr,
waers LIKE bkpf-waers,
ext_num(24) TYPE c,
txt20 LIKE skat-txt20,
usr00 LIKE prps-usr00,
usr01 LIKE prps-usr01,
usr02 LIKE prps-usr02,
usr03 LIKE prps-usr03,

END OF gt_result.

*----------------------------------------------------
CONSTANTS: c_credit(1) TYPE c VALUE 'H',
c_x(1) TYPE c VALUE 'X',
c_en(2) TYPE c VALUE 'EN',
c_mrc(4) TYPE c VALUE 'CA01'.
*====================================================

INITIALIZATION.

PERFORM initialize_variant.

AT SELECTION-SCREEN.

PERFORM pai_of_selection_screen.

*====================================================

START-OF-SELECTION.

REFRESH gt_result.

* find clearing documents

SELECT bukrs
lifnr
augdt
gjahr
belnr
blart
zterm
INTO TABLE gt_bsak
FROM bsak
WHERE bukrs IN s_bukrs
AND lifnr IN s_lifnr
AND augdt IN s_augdt
AND blart IN s_blart
AND zterm IN s_zterm.

CHECK NOT gt_bsak[] IS INITIAL.

LOOP AT gt_bsak.

* read WBS items

SELECT bukrs
belnr
gjahr
dmbtr
projk
shkzg
hkont
INTO TABLE gt_bseg
FROM bseg
WHERE bukrs = gt_bsak-bukrs
AND belnr = gt_bsak-belnr
AND gjahr = gt_bsak-gjahr
AND projk > space.

gt_result-bukrs = gt_bsak-bukrs.
gt_result-lifnr = gt_bsak-lifnr.
gt_result-augdt = gt_bsak-augdt.
gt_result-belnr = gt_bsak-belnr.
gt_result-gjahr = gt_bsak-gjahr.
gt_result-blart = gt_bsak-blart.
gt_result-zterm = gt_bsak-zterm.

* document currency

SELECT SINGLE waers
INTO gt_result-waers
FROM bkpf
WHERE bukrs = gt_bsak-bukrs
AND belnr = gt_bsak-belnr
AND gjahr = gt_bsak-gjahr.

* vendor name
SELECT SINGLE name1
INTO gt_result-name1
FROM lfa1
WHERE lifnr = gt_result-lifnr.

* for each accounting document
LOOP AT gt_bseg.

* convert to external WBS

CALL FUNCTION 'PSPNUM_INTERN_TO_EXTERN_CONV'
EXPORTING
edit_imp = c_x
int_num = gt_bseg-projk
IMPORTING
ext_num = gt_result-ext_num
EXCEPTIONS
not_found = 1
OTHERS = 2.

* debit or credit

IF gt_bseg-shkzg = c_credit.
gt_result-wrbtr = gt_bseg-wrbtr.
ELSE.
gt_result-wrbtr = gt_bseg-wrbtr * -1.
ENDIF.

* GL short Text

SELECT SINGLE txt20
INTO gt_result-txt20
FROM skat
WHERE spras = c_en
AND ktopl = 'CA01'
AND saknr = gt_bseg-hkont.

* user fields

SELECT SINGLE usr00
usr01
usr02
usr03
INTO (gt_result-usr00,
gt_result-usr01,
gt_result-usr02,
gt_result-usr03)
FROM prps
WHERE pspnr = gt_bseg-projk.

* append to result table

APPEND gt_result.
ENDLOOP.
ENDLOOP.

*====================================================
END-OF-SELECTION.


PERFORM initialize_fieldcat USING gt_fieldtab[].

g_variant-report = sy-repid.
g_save = 'A'.

IF s_list = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = gt_fieldtab
i_default = 'A'
i_save = g_save
is_variant = g_variant
TABLES
t_outtab = gt_result.

ELSE.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = gt_fieldtab
i_default = 'A'
i_save = g_save
is_variant = g_variant
TABLES
t_outtab = gt_result.

ENDIF.

*&--------------------------------------------------------------------*
*& Form initialize_variant
*&--------------------------------------------------------------------*

FORM initialize_variant.
g_save = 'A'.
CLEAR g_variant.
g_variant-report = sy-repid.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant
EXCEPTIONS
not_found = 2.

IF sy-subrc = 0.
s_vari = g_variant-variant.
ENDIF.

ENDFORM. " INITIALIZE_VARIANT

*&--------------------------------------------------------------------*
*& Form pai_of_selection_screen
*&--------------------------------------------------------------------*

FORM pai_of_selection_screen.

IF NOT s_vari IS INITIAL.
MOVE s_vari TO g_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant.
ELSE.
PERFORM initialize_variant.
ENDIF.

ENDFORM. " PAI_OF_SELECTION_SCREEN

*&--------------------------------------------------------------------*
*& Form initialize_fieldcat
*&--------------------------------------------------------------------*

FORM initialize_fieldcat USING p_fieldtab TYPE slis_t_fieldcat_alv.
DATA: l_fieldcat TYPE slis_fieldcat_alv.
CLEAR l_fieldcat.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'BUKRS'.
l_fieldcat-seltext_L = 'Company'.
l_fieldcat-outputlen = '8'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'LIFNR'.
l_fieldcat-seltext_L = 'Vendor'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'NAME1'.
l_fieldcat-seltext_L = 'Name'.
l_fieldcat-outputlen = '35'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'AUGDT'.
l_fieldcat-seltext_L = 'Cleared'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'GJAHR'.
l_fieldcat-seltext_L = 'Year'.
l_fieldcat-outputlen = '5'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'BELNR'.
l_fieldcat-seltext_L = 'Document'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'BLART'.
l_fieldcat-seltext_L = 'Type'.
l_fieldcat-outputlen = '4'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'ZTERM'.
l_fieldcat-seltext_L = 'Pay Terms'.
l_fieldcat-outputlen = '4'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'WRBTR'.
l_fieldcat-seltext_L = 'Amount'.
l_fieldcat-outputlen = '13'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'WAERS'.
l_fieldcat-seltext_L = 'CURR'.
l_fieldcat-outputlen = '5'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'EXT_NUM'.
l_fieldcat-seltext_L = 'WBS'.
l_fieldcat-outputlen = '24'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'TXT20'.
l_fieldcat-seltext_L = 'Short Text'.
l_fieldcat-outputlen = '20'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR00'.
l_fieldcat-seltext_L = 'H/O File Ref'.
l_fieldcat-outputlen = '20'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR01'.
l_fieldcat-seltext_L = 'Local File Ref'.
l_fieldcat-outputlen = '20'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR02'.
l_fieldcat-seltext_L = 'INFORM Agree ID'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR03'.
l_fieldcat-seltext_L = 'INFM Prim Ag ID'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
ENDFORM. " INITIALIZE_FIELDCAT
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.