‎2006 Sep 05 4:59 PM
experts,
i need u r help.
plz help to write the code for the below.
can i write one select for the given based on condition or need to write two selects.
kindly help me.
Order_Date:
1. If billing document type (VBFA-VBTYP_N) = M, then select from VBFA the preceding document (VBFA-VBELV) where the billing document (VBRK-VBELN) is equal to the follow on document (VBFA-VBELN).
a. Select from VBFA the preceding document (VBFA-VBELV) where the preceding document (VBFA-VBELV) in step 1 is equal to the follow on document (VBFA-VBELN)
b. Select from VBAK the order date (VBAK-ERDAT) where the document selected in step 1a (VBFA-VBELV) is equal to the order (VBAK-VBELN)
2. If billing document type (VBFA-VBTYP_N) = H or O or P, then select from VBFA the preceding document (VBFA-VBELV) where the billing document (VBRK-VBELN) is equal to the follow on document (VBFA-VBELN).
a. Select from VBAK the order date (VBAK-ERDAT) where the document selected in step 2 (VBFA-VBELV) is equal to the order (VBAK-VBELN)
regards,
VC
‎2006 Sep 05 5:11 PM
Hi
U can use fm RV_ORDER_FLOW_INFORMATION to pick up whole flow of sale document.
Max
‎2006 Sep 05 5:11 PM
Hi
U can use fm RV_ORDER_FLOW_INFORMATION to pick up whole flow of sale document.
Max
‎2006 Sep 05 5:18 PM
hi Max
actually i need to write select quirre for this.
as u told how to use RV_ORDER_FLOW_INFORMATION
in my code.
regards,
VC
‎2006 Sep 05 5:27 PM
‎2006 Sep 05 5:27 PM
‎2006 Sep 05 5:29 PM
Hi
You have to indicate the document number (so I suppose the bill (?)) and fm return all data of VBFA you need:
TABLES VBCO6.
PARAMETERS: SO_VBELN FOR VBRK-VBELN.
DATA: T_VBRK LIKE STANDARD TABLE OF VBRK WITH HEADER LINE,
T_VBFA LIKE STANDARD TABLE OF VBRK WITH HEADER LINE.
SELECT * FROM VBRK INTO TABLE T_VBRK WHERE VBELN IN SO_VBELN.
LOOP AT T_VBRK.
REFRESH T_VBFA.
VBCO6-VBELN = T_VBRK-VBELN.
CALL FUNCTION 'RV_ORDER_FLOW_INFORMATION'
EXPORTING
COMWA = VBCO6
IMPORTING
BELEGTYP_BACK =
TABLES
VBFA_TAB = T_VBFA
EXCEPTIONS
NO_VBFA = 1
NO_VBUK_FOUND = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Here read T_VBFA (instead of VBFA)
LOOP AT T_VBFA WHERE...
ENDLOOP.
ENDLOOP.
Anyway u should considere if you need the data of sales order that generated a certain bill, you don't need to read VBFA, because you can pick the number of the order from item data:
DATA: BEGIN OF T_VBRP OCCURS 0,
VBELN TYPE VBELN,
VGBEL TYPE VGBEL,
END OF T_VBRP.
SELECT VBELN VGBEL FROM VBRP INTO TABLE T_VBRP
FOR ALL ENRIES IN T_VBRK
WHERE VBELN = T_VBRK-VBELN.
SORT T_VBRP BY VBELN VGBEL.
DELETE ADJACENT DUPLICATES FROM T_VBRP.
LOOP AT T_VBRK.
LOOP AT T_VBRP WHERE VBELN = T_VBRP-VBELN.
SELECT SINGLE * FROM VBAK WHERE VBELN = T_VBRP-VGBEL.
ENDLOOP.
ENDLOOP.
Max