Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Add billing date in existing prog when goes through VF01

Former Member
0 Kudos

How do I add the billing date as sy-datum in my program that uses BDC to create billing documenst for the sales order in the output . I would like this to take te billing date as sy-datum. I know if if I add the billing date as todays date while generating biling documenst for multiple selections of sales order it will process and create a billing doc for it, right now which si not happening as billing date is missing. I want to add the billing date in BDC. Could I get some help please. In the below case only for p_rdos.

*&---------------------------------------------------------------------*
*&      Form  process_vf01
*&---------------------------------------------------------------------*
*       Call transaction VF01 and fill screen table with order values
*----------------------------------------------------------------------*
FORM process_vf01.
  DATA: ln_index(2) TYPE n,
        lc_field(20) TYPE c,
        lc_fkart TYPE vbrk-fkart,
        li_lines TYPE i,
        lc_msgtxt(99) TYPE c,
        lwa_bdcoptions TYPE ctu_params,
        lwa_mess LIKE LINE OF it_bdcmess,
*        lc_date like vbrk-fkdat.
        lc_date like sy-datum.

  REFRESH: it_bdcmess.

  lwa_bdcoptions-dismode = cns_mode.
  lwa_bdcoptions-updmode = cns_upd.

  CASE 'X'.
    WHEN p_rdff.
      lc_fkart = cns_fkff.
    WHEN p_rdos.
      lc_fkart = cns_fkos.
      lc_date = sy-datum.
  ENDCASE.

  DESCRIBE TABLE it_vbeln LINES li_lines.

  REFRESH: bdc_tab.
  PERFORM update_bdc USING: 'X' 'SAPMV60A'    '0102',
                            ' ' 'BDC_CURSOR'  'RV60A-FKART',
                            ' ' 'RV60A-FKART' lc_fkart,
                            ' ' 'BDC_OKCODE' '/00'.

  LOOP AT it_vbeln INTO wa_vbeln.
    ln_index = sy-tabix.

*   Up to the second delivery of the BDC add the Delivery to the screen,
*   after that click the More Documents for every entry.  logic changed for DEVK902353
*   changed again in added for every line DEVK910604
    CASE ln_index.
      WHEN 1.
        CONCATENATE 'KOMFK-VBELN' '(' ln_index ')' INTO lc_field.
        IF li_lines = 1.
          PERFORM update_bdc USING: ' ' lc_field wa_vbeln.
        ELSE.

          PERFORM update_bdc USING: ' ' lc_field wa_vbeln,
                                    ' ' 'BDC_OKCODE' 'FKAN'.
              ENDIF.
      WHEN OTHERS.
*        IF p_rdos  <> 'X'.
        CONCATENATE 'KOMFK-VBELN' '(2)' INTO lc_field.

        PERFORM update_bdc USING: ' ' lc_field wa_vbeln,
                                  'X' 'SAPMV60A'   '0102',
                                  ' ' 'BDC_OKCODE' 'FKAN'.


    ENDCASE.

  ENDLOOP.

* VF01 will go to a different screen if only one line selected
  IF li_lines EQ 1.
    PERFORM update_bdc USING: 'X' 'SAPMV60A' '0104',
                              ' ' 'BDC_OKCODE' '=SICH'.
  ELSE.
    PERFORM update_bdc USING: 'X' 'SAPMV60A' '0102',
                              ' ' 'BDC_OKCODE' '=SICH'.


  ENDIF.

  CALL TRANSACTION 'VF01'  USING bdc_tab OPTIONS FROM lwa_bdcoptions
                          MESSAGES INTO it_bdcmess.

  WRITE: / 'BDC Messages:'.
  SKIP.
  LOOP AT it_bdcmess INTO lwa_mess.

    CALL FUNCTION 'RH_MESSAGE_GET'
      EXPORTING
        arbgb             = 'VF'
        msgnr             = lwa_mess-msgnr
        msgv1             = lwa_mess-msgv1
        msgv2             = lwa_mess-msgv2
        msgv3             = lwa_mess-msgv3
        msgv4             = lwa_mess-msgv4
      IMPORTING
        msgtext           = lc_msgtxt
      EXCEPTIONS
        message_not_found = 1
        OTHERS            = 2.

    WRITE: /5 lc_msgtxt.

  ENDLOOP.


ENDFORM.                    " process_vf01

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Can anyone please help me with this please.

Thanks

14 REPLIES 14

Former Member
0 Kudos

Can anyone please help me with this please.

Thanks

0 Kudos

instead of bdc u can try creating invoices thru the fm rv_invoice_create

0 Kudos

how do I use this FM and wher in my program ? Wont adding the billing date (sy-datum) in the BDC help . I am not sure how to go about doing it.

Thanks

0 Kudos

Just add the current date to screen field RV60A-FKDAT in screen 0102 of program SAPMV60A

REFRESH: bdc_tab.

PERFORM update_bdc USING: 'X' 'SAPMV60A' '0102',

' ' 'BDC_CURSOR' 'RV60A-FKART',

' 'RV60A-FKART' lc_fkart

'RV60A-FKDAT' sy-datum

' ' 'BDC_OKCODE' '/00'.

LOOP AT it_vbeln INTO wa_vbeln.

ln_index = sy-tabix.

.......

It should solve your problem

Regards,

Sreenivasa sarma K

0 Kudos

adding the date field to the bdc will do but generally bdc is the last option we prefer, if fm or bapi is present it is used instead. They give much better performance then bdc.

0 Kudos

added that in the code , but when I run the program with a selection , the output shows two sales orders nad when I try generating bill document I get a BDC message as follows and no doc is generated.

BDC Messages:

Please enter file for output

Document __/__/____ is blocked for billing

dont know what this msg mean but I get it as this.

Thanks

0 Kudos

Do I have to add anything in the recording too and again process it or just adding here will help out.Right now I get message as above.

0 Kudos

if u debug vf01 u'll that this transaction also calls this fm so if u directly use this fm it would give better performance, i'll give u its sample code once i reach my sap system in some time

U can check this thread on sample code to call this fm

Edited by: kartik tarla on Apr 3, 2009 7:58 AM

0 Kudos

Thanks will wait for it .

0 Kudos

Hi aarav,

Please follow the kartik instructions....if you still want BDC.... the error you are getting its may be becoz of date format.

declare variable like

date : lv_fkdat type sy-datum.

     write sy-datum to lv_fkdat.

     and pass the lv_fkdat to screen field.
    'RV60A-FKDAT'  lv_fkdat

Regards,

Sreenivasa Sarma K

0 Kudos

I would like to do it from the BDC as thats the existing prog and would be good if it worked this way. I have added that itself in mt progr.

        lc_date like sy-datum.

  REFRESH: it_bdcmess.

  lwa_bdcoptions-dismode = cns_mode.
  lwa_bdcoptions-updmode = cns_upd.

  CASE 'X'.
    WHEN p_rdff.
      lc_fkart = cns_fkff.
    WHEN p_rdos.
      lc_fkart = cns_fkos.
      lc_date = sy-datum.
  ENDCASE.

  DESCRIBE TABLE it_vbeln LINES li_lines.

  REFRESH: bdc_tab.
  PERFORM update_bdc USING: 'X' 'SAPMV60A'    '0102',
                            ' ' 'BDC_CURSOR'  'RV60A-FKART',
                            ' ' 'RV60A-FKART' lc_fkart,
                            ' ' 'RV60A-FKDAT' lc_date,
                            ' ' 'BDC_OKCODE' '/00'.

still I get a message.

BDC Messages:

Check the log

No billing documents were generated. See log

Incorrect document category SAPMV60A in RV_INVOICE_DOCUMENT_ADD

0 Kudos

I added as u said :

write sy-datum to lc_date.

but the message is same

0 Kudos

u can chk this code


data:  wa_vbsk TYPE vbsk,
 wa_vbsk-smart = c_f.
 APPEND wa_komfk TO it_komfk.
        CLEAR wa_komfk.

        CALL FUNCTION 'RV_INVOICE_CREATE'
                EXPORTING
*                 delivery_date             = 0
                 invoice_date              = v_date "ur current date
*                 invoice_type              = '    '
*                 pricing_date              = 0
                 vbsk_i                    = wa_vbsk
                 with_posting              = 'D'
*                 select_date               = 0
                 i_no_vblog                = ' '
                 i_analyze_mode            = ' '
                 id_utasy                  = ' '
                 id_utswl                  = ' '
                 id_utsnl                  = ' '
                 id_no_enqueue             = ' '
                 id_new_cancellation       = ' '
**             IMPORTING
*               VBSK_E                    =
*               OD_BAD_DATA               =
*               DET_REBATE                =
                TABLES
                  xkomfk                    = it_komfk
                  xkomv                     = it_komv
                  xthead                    = it_thead
                  xvbfs                     = it_vbfs
                  xvbpa                     = it_vbpa
                  xvbrk                     = it_xvbrk
                  xvbrp                     = it_vbrp
                  xvbss                     = it_vbss
*               XKOMFKGN                  =
*               XKOMFKKO                  =
                        .

Edited by: kartik tarla on Apr 3, 2009 10:28 AM

0 Kudos

Hi aarav,

Is your problem solved or still the problem is persisting ?

regards,

sreenivasa sarma