Report output as per order of material in variant

Dear Friends,
I have developed a report that reports production figures of different materials, sorted by material (alphabetically).
The requirement of the user is that the list should be as per the order of different materials mentioned in the variant.
How can I achieve this? Please advice.
Regards,
Alok.

hi,
u sort the internal table by the materials in our variant.
like sort itab by jtab
itab consists of all materials
jtab cosists of materials in variant.
hope it may helpful,
regards,
chandu

Similar Messages

  • Output Type - Sales Order Type & Material Combination

    Hi Guys,
    I would like to know if there is away to Trigger an Output for a Sales Order IF and ONLY IF  if it is of a Certain SalesOrder Type and Material Combination.
    Can you please let me know the step by step process.
    Thanks for your Help,
    Best Regards,
    Bharat.

    It is possible to Trigger an Output for a Sales Order.
    There will be two structures which should be visible within your VOFM routine.
    KOMKBV1
    and KOMPBV1.
    VOFM Transaction (Requirements -> Output control)
    Check this sample code.
    Routine 610 (program RV61B601)
    FORM KOBED_601.
      SY-SUBRC = 0.
    ENDFORM.
    FORM KOBEV_601.
      SY-SUBRC = 0.
    if komkbv1-auart = 'XXXX' and kompbv1-matnr = 'YYYY'.
    sy-subrc = 0.
    else.
    sy-subrc = 4.
    ENDFORM.

  • ALV Report output as per selection screen

    Hi,
    I got a requirement. In selection screen there is field where i can entered 1 to 12 numbers. When i entered a number,  so that in output of an alv report should display that many fields
    for eg.
    if  i entered 5 in selection screen
    in out put 5 fields of alv report should display.
    Thanks....
    Moderator message : Spec dumping / Outsourcing is not allowed. Thread locked.
    Edited by: Vinod Kumar on Jul 15, 2011 11:34 AM

    hi,
    u sort the internal table by the materials in our variant.
    like sort itab by jtab
    itab consists of all materials
    jtab cosists of materials in variant.
    hope it may helpful,
    regards,
    chandu

  • Creditreport that displays Sales Orders with Material Availability Date as

    Hi
    I need input if the following requirement can be met in FSCM credit mgmnt.
    Currently In FDK43 there is a total sales figure that represents the Sales that are consuming the Credit Limit assigned to the customer, unfortunately there is no drill down on this number to see which sales orders are responsible for the consumption of credit
    Do we have any sales report that displays Sales Orders with Material Availability Date as an output in conjunction with Credit limit .

    Not in standard provided. Custom program is required.
    Regards
    Hein

  • Report output - - - Urgent

    I have an existing report. The first data field is concatenation of three fields and this fields data is like the following
    ABCD ( X12 )
    DEFF ( Y34 )
    GSSD ( TST )
    Here I need to get the data output in the order of values within the parentheses instead of starting values of the fields data. Desired output should be like
    GSSD ( TST )
    ABCD ( X12 )
    DEFF ( Y34 )
    To get these values I have added an order by clause to the existing query like
    ORDER BY SUBSTR (field_name, INSTR (field_name, ( ) )
    But I havent got the report output in required order. (ButIf I check this query in SQL I am getting the values in desired order).
    Please tell me a solution to resolve this issue (because existing report is quite complex and I dont want to create this report from scratch).
    Thank you in advance
    Prasad
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Ileana Bblcu ([email protected]):
    I suppose this is the master group of a query and you also have a detail group. The detail group is ordered by the order by in aselect, but the master group is ordered by the break order. Add the substr... as a column to the query. In the Data model move this new column as the first one in the group, so the break order will be dictated by it.<HR></BLOCKQUOTE>
    Thank you for response... i did try that scenario before but it wasn't work.
    null

  • Change order of key figure is not working in Web report output (using WAD)

    Hi,
    We are using BI 7.0, release 701 and level 008. We are facing problem in WAD (web report output). When ever we do 'Select filter' for key figures and 'change the order' of key figures, it does not get reflected in new order. Though drag and drop of key figures is working.
    Though same change order is working fine in Bex Analyser.
    Kindly suggest some inputs.
    Thanks.

    Hi,
    On Which Service Pack are you on?WAD has this feature of re arranging the keyfigures in BI 7.0 for SPS 14...
    Regards,
    Bhagyarekha.

  • Out of stock material report based on sales orders

    Hi,
    I have a requirement to create a report where I need to show the unfulfilled sales orders due to materials were out of stock for those sales orders.
    e.g. there were 3 orders placed yesterday. we partialy delivered order - 1 as one of the material was available but second material was out of stock and order - 2 was not delivered at all due to out of stock materail and order - 3 was delivered completely
    Header 1
    Header 2
    Header 3
    sales order
    material
    quantity
    order -  1
    mat -1
    0
    mat - 2
    2
    order - 2
    mat-3
    0
    order - 3
    mat - 4
    2
    required out put it to show only those sales orders which has 0 quantity materials.
    Header 1
    Header 2
    Header 3
    sales order
    material
    quantity
    order -  1
    mat -1
    0
    order - 2
    mat-3
    0
    any advice on data modeling as to how do i achieve this?
    Which dataosurces shall i use?
    regards,
    Biapp

    Hi Gajesh,
    I have looked in to the material availability date and it gives me the required result about 80%.
    only problem is e.g.
    if the customer placed order for a material for 10qty and if we had 5 in stock same day and the rest of the 5 qty is available after the month but material availability picks up that 5 qty and it does not show that we were not able to fullfill the order 100%. material availability date does not pick up the second date.
    how do i overcome this issue? do you have any idea?
    regards,
    BIapp

  • Report which include sales order, material, qty, raw mat cost, sold gds cst

    Dear All,
    I want report which has to provide Sales order No, Material, Material Description, Raw material cost and Cost of sold goods.
    Please suggest
    Regards

    Hi,
    VA05 return all the orders that are present under one customer.
    It will give you customer number,material and material description etc...
    But failed in other fields.
    So you have to develop a Z report with the help of your ABAPer.
    Regards,
    Krishna.

  • Report for spending per material group

    Hi Gurus,
    Is there a report that will show us the total spend per material group
    Thanks
    Anusha

    Try LIS reports starting with MC*. For material group purchasing values you can try MC$<.
    Thanks...

  • Sending report output via E-mail (excel pivoted format)

    Hi all,
    i have a written a report where i need to send the report output to somebody via
    E-mail.i am sending this report output via E-mail successfully.The receiver receives, my output in excel format.but this excel is not <b>pivoted</b>.
    i want , the receiver should get my output in pivoted excel format.i.e my output data should be exactly fit in the excel sheet.
    now the columns in excel sheet are overlapping.once i double clicked, the columns are getting separated.i do not want to double click.i want all the columns should come properly i.e excel field  length should be adjusted as per the output field length.
    i am giving my coding below.plz suggest how i can do the above thing .it's urgent.
    any idea will be highly appreaciated.
    Regards
    if not p_email1 is initial.
         perform fill_report_csv.
         perform f_send_internet_mail.
      endif.
    FORM fill_report_csv.
       data :   l_text(232) type c,
               v_matnr1(21) type c,
               v_matnr(21) type c,
               v_matkl(14) type c,
               v_maktx(45) type c,
               v_ttlstk(14) type c,
               v_verpr(14) type c,
               v_werks(14) type c,
               v_lgort(14) type c,
               v_char(10) type c,
               v_stks type p ,
               v_po(40) type c,
               v_qty(13) type c,
                v_qty1 type sy-datum,
               v_date(15) type c,
               v_date1(15) TYPE C,
               v_name(35) type c,
               v_eknam(18) type c,
               v_lifnr(15) type c,
            l_po(40) type c,
            v_matnr(20) type c,
             l_rate(11) type  p decimals 5,
             l_flag type c.
      concatenate c_equal c_colon 'PO no.' c_colon
                    into v_po.
      concatenate c_equal c_colon 'Material no.' c_colon
                    into v_matnr.
      concatenate c_equal c_colon 'Description.' c_colon
                    into v_maktx.
      concatenate c_equal c_colon 'Due Qty.' c_colon
                    into v_qty.
      concatenate c_equal c_colon 'Del Date.' c_colon
                    into v_date.
      concatenate c_equal c_colon 'Vendor.' c_colon
                    into v_name.
      concatenate c_equal c_colon 'Buyer.' c_colon
                    into v_eknam.
      concatenate c_equal c_colon 'Vendor Code.' c_colon
                    into v_lifnr.
    concatenate
             v_po v_matnr v_maktx v_qty
             v_date v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
      append i_download .
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    clear wa_output.
    loop at i_output into wa_output.
       on change of wa_output-ebeln.
         clear v_lines.
         loop at i_eket into wa_eket
                 where ebeln = wa_output-ebeln.
           v_lines = v_lines + 1.
           clear wa_eket.
         endloop.
    **-- Checking of page break
         v_lines = sy-linno + v_lines .
         if 55 < v_lines  .
           write:/0(161) sy-uline.
           new-page.
         endif.
      clear v_lines.
          loop at i_eket into wa_eket
                  where ebeln = wa_output-ebeln.
            v_lines = v_lines + 1.
            clear wa_eket.
          endloop.
    *-- Calculating the due qty.
        wa_output-dumng = wa_output-menge - wa_output-wemng.
    *-- Writing the Line items of the PO.
        read table i_ekpo into wa_ekpo
              with key ebeln = wa_output-ebeln
                       ebelp = wa_output-ebelp.
         l_rate = wa_ekpo-netpr / wa_ekpo-peinh.
    *-- Writing of PO detail
         if wa_output-dumng gt 0 .
         v_qty = wa_output-dumng.
        v_date1 = wa_output-eindt.
        v_maktx = wa_output-maktx.
         if wa_output-maktx+0(1) = '"' .
                concatenate  c_equal wa_output-maktx
                   into v_maktx  .
             else .
                concatenate  c_equal c_colon wa_output-maktx c_colon
                   into v_maktx  .
             endif .
       if wa_output-name1+0(1) = '"' .
                concatenate  c_equal wa_output-name1
                   into v_name  .
             else .
                concatenate  c_equal c_colon wa_output-name1 c_colon
                   into v_name  .
             endif .
        v_name = wa_output-name1.
        v_lifnr = wa_output-lifnr.
         write wa_output-eindt to v_date1 DD/MM/YYYY.
         concatenate '="' wa_output-ebeln '/'
                wa_output-ebelp '"' into v_po .
         concatenate '="' wa_output-matnr '"' into v_matnr .
             concatenate  c_equal c_colon wa_output-maktx c_colon
               into v_maktx  .
              concatenate  c_equal c_colon wa_output-dumng c_colon
               into v_qty1  .
               concatenate  c_equal c_colon wa_output-eindt c_colon
               into v_date1  .
              concatenate  c_equal c_colon wa_output-name1 c_colon
               into v_name  .
                concatenate  c_equal c_colon wa_output-eknam c_colon
                into v_eknam  .
              concatenate  c_equal c_colon wa_output-lifnr c_colon
               into v_lifnr  .
              concatenate  c_equal c_colon wa_mard-werks '/'
               wa_mard-lgort c_colon
               into v_lgort .
                 concatenate '="' wa_output-lifnr '"' into v_lifnr .
    condense:v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
         concatenate
             v_po v_matnr v_maktx v_qty
             v_date1 v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
        concatenate con_cret i_download INTO i_download .
        append i_download .
      endif.
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    endloop.
    ENDFORM.                    " fill_report_csv
    *&      Form  f_send_internet_mail
          text
    -->  p1        text
    <--  p2        text
    FORM f_send_internet_mail.
    Variables
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    data : found_receiver type c,
           v_title(80) type c,
           l_text(180) type c.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Adds text to email text table
      append 'Pls see attached open purchase order report.' to it_message.
      append '' to it_message.
      concatenate 'Note: This is system generated report'
                  ', figures may subject to actual physical count.'
                  into l_text separated by space.
      append l_text to it_message.
    Populate the subject/generic message attributes
      CLEAR gd_doc_data.
      READ TABLE i_download INDEX w_cnt.
      gd_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( i_download ).
      gd_doc_data-obj_langu  = sy-langu.
      gd_doc_data-obj_name   = 'SAPRPT'.
    if p_asdate is initial .
         concatenate p_title ' '
                  sy-datum sy-uzeit into v_title separated by space.
    else .
        concatenate p_title ' '
                 p_bldat p_cputm into v_title separated by space.
    endif .
      gd_doc_data-obj_descr  = v_title .
      gd_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = i_download[].
    Describe the body of the message
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    Create attachment notification
      it_packing_list-transf_bin = 'X'.
      it_packing_list-head_start = 1.
      it_packing_list-head_num   = 1.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES it_packing_list-body_num.
      it_packing_list-doc_type   =  'XLS'.
      it_packing_list-obj_descr  =  'OPEN PURCHASE ORDER' .
      it_packing_list-obj_name   =  'PO.XLS' .
      it_packing_list-doc_size   =  it_packing_list-body_num * 255.
      APPEND it_packing_list.
    assign SAP user smtp address from successful retrieval.
      loop at p_email.
    Add the recipients email address
         found_receiver = 'X' .
         it_receivers-receiver = p_email-low.
         it_receivers-rec_type = 'U'.
         it_receivers-com_type = 'INT'.
         it_receivers-notif_del = ''.
         it_receivers-notif_ndel = 'X'.
         append it_receivers .
      endloop .
    Add default recipient email when unable to locate purc group email
       if found_receiver is initial .
           it_receivers-receiver = p_email.
           it_receivers-rec_type = 'U'.
           it_receivers-com_type = 'INT'.
           it_receivers-notif_del = ''.
           it_receivers-notif_ndel = 'X'.
          append it_receivers.
       endif .
    Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
                commit_work                = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = it_receivers
           exceptions
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                others                     = 8.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.
    Instructs mail send program for SAPCONNECT to send email.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = ' '
                        and return.
      endif.
    ENDFORM.                    " f_send_internet_mail

    Hi,
    go through this link,
    http://www.sapdevelopment.co.uk/reporting/email/emailhome.htm
    you have some sample programs.
    Regards,
    Raghavendra

  • Report output via E-mail

    Hi all,
    i have a written a report where i need to send the report output to somebody via
    E-mail.i am sending this report output via E-mail successfully.The receiver receives, my output in excel format.but this excel is not <b>pivoted</b>.
    i want , the receiver should get my output in pivoted excel format.i.e my output data should be exactly fit in the excel sheet.
    now the columns in excel sheet are overlapping.once i double clicked, the columns are getting separated.i do not want to double click.i want all the columns should come properly i.e excel field  length should be adjusted as per the output field length.
    i am giving my coding below.plz suggest how i can do the above thing .it's urgent.
    any idea will be highly appreaciated.
    Regards
    if not p_email1 is initial.
         perform fill_report_csv.
         perform f_send_internet_mail.
      endif.
    FORM fill_report_csv.
       data :   l_text(232) type c,
               v_matnr1(21) type c,
               v_matnr(21) type c,
               v_matkl(14) type c,
               v_maktx(45) type c,
               v_ttlstk(14) type c,
               v_verpr(14) type c,
               v_werks(14) type c,
               v_lgort(14) type c,
               v_char(10) type c,
               v_stks type p ,
               v_po(40) type c,
               v_qty(13) type c,
                v_qty1 type sy-datum,
               v_date(15) type c,
               v_date1(15) TYPE C,
               v_name(35) type c,
               v_eknam(18) type c,
               v_lifnr(15) type c,
            l_po(40) type c,
            v_matnr(20) type c,
             l_rate(11) type  p decimals 5,
             l_flag type c.
      concatenate c_equal c_colon 'PO no.' c_colon
                    into v_po.
      concatenate c_equal c_colon 'Material no.' c_colon
                    into v_matnr.
      concatenate c_equal c_colon 'Description.' c_colon
                    into v_maktx.
      concatenate c_equal c_colon 'Due Qty.' c_colon
                    into v_qty.
      concatenate c_equal c_colon 'Del Date.' c_colon
                    into v_date.
      concatenate c_equal c_colon 'Vendor.' c_colon
                    into v_name.
      concatenate c_equal c_colon 'Buyer.' c_colon
                    into v_eknam.
      concatenate c_equal c_colon 'Vendor Code.' c_colon
                    into v_lifnr.
    concatenate
             v_po v_matnr v_maktx v_qty
             v_date v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
      append i_download .
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    clear wa_output.
    loop at i_output into wa_output.
       on change of wa_output-ebeln.
         clear v_lines.
         loop at i_eket into wa_eket
                 where ebeln = wa_output-ebeln.
           v_lines = v_lines + 1.
           clear wa_eket.
         endloop.
    **-- Checking of page break
         v_lines = sy-linno + v_lines .
         if 55 < v_lines  .
           write:/0(161) sy-uline.
           new-page.
         endif.
      clear v_lines.
          loop at i_eket into wa_eket
                  where ebeln = wa_output-ebeln.
            v_lines = v_lines + 1.
            clear wa_eket.
          endloop.
    *-- Calculating the due qty.
        wa_output-dumng = wa_output-menge - wa_output-wemng.
    *-- Writing the Line items of the PO.
        read table i_ekpo into wa_ekpo
              with key ebeln = wa_output-ebeln
                       ebelp = wa_output-ebelp.
         l_rate = wa_ekpo-netpr / wa_ekpo-peinh.
    *-- Writing of PO detail
         if wa_output-dumng gt 0 .
         v_qty = wa_output-dumng.
        v_date1 = wa_output-eindt.
        v_maktx = wa_output-maktx.
         if wa_output-maktx+0(1) = '"' .
                concatenate  c_equal wa_output-maktx
                   into v_maktx  .
             else .
                concatenate  c_equal c_colon wa_output-maktx c_colon
                   into v_maktx  .
             endif .
       if wa_output-name1+0(1) = '"' .
                concatenate  c_equal wa_output-name1
                   into v_name  .
             else .
                concatenate  c_equal c_colon wa_output-name1 c_colon
                   into v_name  .
             endif .
        v_name = wa_output-name1.
        v_lifnr = wa_output-lifnr.
         write wa_output-eindt to v_date1 DD/MM/YYYY.
         concatenate '="' wa_output-ebeln '/'
                wa_output-ebelp '"' into v_po .
         concatenate '="' wa_output-matnr '"' into v_matnr .
             concatenate  c_equal c_colon wa_output-maktx c_colon
               into v_maktx  .
              concatenate  c_equal c_colon wa_output-dumng c_colon
               into v_qty1  .
               concatenate  c_equal c_colon wa_output-eindt c_colon
               into v_date1  .
              concatenate  c_equal c_colon wa_output-name1 c_colon
               into v_name  .
                concatenate  c_equal c_colon wa_output-eknam c_colon
                into v_eknam  .
              concatenate  c_equal c_colon wa_output-lifnr c_colon
               into v_lifnr  .
              concatenate  c_equal c_colon wa_mard-werks '/'
               wa_mard-lgort c_colon
               into v_lgort .
                 concatenate '="' wa_output-lifnr '"' into v_lifnr .
    condense:v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
         concatenate
             v_po v_matnr v_maktx v_qty
             v_date1 v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
        concatenate con_cret i_download INTO i_download .
        append i_download .
      endif.
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    endloop.
    ENDFORM.                    " fill_report_csv
    *&      Form  f_send_internet_mail
          text
    -->  p1        text
    <--  p2        text
    FORM f_send_internet_mail.
    Variables
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    data : found_receiver type c,
           v_title(80) type c,
           l_text(180) type c.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Adds text to email text table
      append 'Pls see attached open purchase order report.' to it_message.
      append '' to it_message.
      concatenate 'Note: This is system generated report'
                  ', figures may subject to actual physical count.'
                  into l_text separated by space.
      append l_text to it_message.
    Populate the subject/generic message attributes
      CLEAR gd_doc_data.
      READ TABLE i_download INDEX w_cnt.
      gd_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( i_download ).
      gd_doc_data-obj_langu  = sy-langu.
      gd_doc_data-obj_name   = 'SAPRPT'.
    if p_asdate is initial .
         concatenate p_title ' '
                  sy-datum sy-uzeit into v_title separated by space.
    else .
        concatenate p_title ' '
                 p_bldat p_cputm into v_title separated by space.
    endif .
      gd_doc_data-obj_descr  = v_title .
      gd_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = i_download[].
    Describe the body of the message
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    Create attachment notification
      it_packing_list-transf_bin = 'X'.
      it_packing_list-head_start = 1.
      it_packing_list-head_num   = 1.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES it_packing_list-body_num.
      it_packing_list-doc_type   =  'XLS'.
      it_packing_list-obj_descr  =  'OPEN PURCHASE ORDER' .
      it_packing_list-obj_name   =  'PO.XLS' .
      it_packing_list-doc_size   =  it_packing_list-body_num * 255.
      APPEND it_packing_list.
    assign SAP user smtp address from successful retrieval.
      loop at p_email.
    Add the recipients email address
         found_receiver = 'X' .
         it_receivers-receiver = p_email-low.
         it_receivers-rec_type = 'U'.
         it_receivers-com_type = 'INT'.
         it_receivers-notif_del = ''.
         it_receivers-notif_ndel = 'X'.
         append it_receivers .
      endloop .
    Add default recipient email when unable to locate purc group email
       if found_receiver is initial .
           it_receivers-receiver = p_email.
           it_receivers-rec_type = 'U'.
           it_receivers-com_type = 'INT'.
           it_receivers-notif_del = ''.
           it_receivers-notif_ndel = 'X'.
          append it_receivers.
       endif .
    Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
                commit_work                = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = it_receivers
           exceptions
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                others                     = 8.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.
    Instructs mail send program for SAPCONNECT to send email.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = ' '
                        and return.
      endif.
    ENDFORM.                    " f_send_internet_mail

    ans

  • Requirement Standard SAP Report on Total Purchase Order Value

    Dear Friends,
    Could u please suggest is there any standard SAP report. Requirement has given belwo.
    I required if we have account assignment  Category A as one of inputs, we will get the reqd output  " Total Purcchase order value."
    Note 1) Total Purchase Order Value means - Basic price + taxes + Charges (Freight + Other charges - Discounts etc)
    Note 2) My requirement standard SAP report only.
    Thanks and regrds,
    Vijay Kumar TVN

    Hi,
    T code : ME80FN
    Select :Edit->Dynamic selections>Purchasing document item> Acct. assignment cat.>select A(f4)->execute
    select Material no., PO Number in program selections
    Hope it shall resolve your query....
    regards
    rahul

  • Report output to a file

    Hi All,
    My requirement is on execution of a report ,this report output should be downloaded as a file prompting the user to select the location.
    Can any one help me in downloading the output format to a file. I need some inputs on the  approach for doing this .
    Thanks in advance .
    Padma

    Hi
    See the sample code in which the download to file is used
    and do accordingly
    instaed of the OLE..fun module you can use the GUI_DOWNLOAD also
    report zesdr001
           line-size 215
           line-count 65
           no standard page heading
           message-id zv.
                          Tables Declaration
    tables:vbrk,       " Sales Document: Billing Header Data
           mara,       " Material Master Data
           mbew,       " Material Valuation data
           mbewh,      " Material Valuation: History Data
           t001,       " Company Codes
           t001w,      " Plants/Branches
           konv,       " Pricing Conditions Data
           t179t,      " Materials: Product hierarchies: Texts
           tcurx,      " Currency Conversion Table
           vbuk,       " Sales Document: Header Status data
           tvko,       " Organizational Unit: Sales Organizations
           tvtw,       " Organizational Unit: Dist.Channels
           tspa,       " Organizational Unit: Divisions
           tvfk,       " Billing Document Types
           kna1.       " Customer Master Data
                 Declaration of Data and Internal Tables
    Internal table to store the Billing Details data.(VBRK,VBRP)
    data: begin of itab_bill occurs 0,
            vbeln like vbrk-vbeln,            " Billing Document Number
            fktyp like vbrk-fktyp,            " Billing Category
            vbtyp like vbrk-vbtyp,            " Sales Doc Category
            fkdat like vbrk-fkdat,            " Billing doc date
            fkart like vbrk-fkart,            " Billing Doc type
            bukrs like vbrk-bukrs,            " Company Code
            kurrf like vbrk-kurrf,            " Exchange type
            knumv like vbrk-knumv,            " Condition Number
            waerk like vbrk-waerk,            " Currency
            kunag like vbrk-kunag,            " Sold to Party
            vrkme like vbrp-vrkme,            " sales Unit
            posnr like vbrp-posnr,            " Item Number
            charg like vbrp-charg,            " Batch Number
            fkimg like vbrp-fkimg,            " Billed quantity
            werks like vbrp-werks,            " Plant
            matnr like vbrp-matnr,            " Material Number
            netwr like vbrp-netwr,            " Net Value of the doc
            wavwr like vbrp-wavwr,            " Cost in Doc Currency
            kdmat like vbap-kdmat,            " Customer Material
          end of itab_bill.
    Internal table to write the report output when Customer Mode
    Radiobutton is selected
    data: begin of itab_out occurs 0,
            kunag like vbrk-kunag,            " Customer No
            vbeln like vbrk-vbeln,            " Billing Document Number
            fkart like vbrk-fkart,            " Billing Doc type
            fktyp like vbrk-fktyp,            " Billing Category
            vbtyp like vbrk-vbtyp,            " Sales Doc Category
            fkdat like vbrk-fkdat,            " Billing doc date
            kunnr like kna1-kunnr,            " Customer
            bukrs like vbrk-bukrs,            " Company Code
            kurrf like vbrk-kurrf,            " Exchange Rate
            waerk like vbrk-waerk,            " Currency
            vrkme like vbrp-vrkme,            " Sales Unit
            posnr like vbrp-posnr,            " Item Number
            charg like vbrp-charg,            " Batch Number
            fkimg like vbrp-fkimg,            " Billed quantity
            werks like vbrp-werks,            " Plant
            matnr like vbrp-matnr,            " Material NUmber
            kdmat like vbap-kdmat,            " Customer Material
            bil_amt(16) type p decimals 2,    " Bill Amount
            mode(10),                         " Mode
            density(10),                      " Density
            sel_prc(16) type p decimals 2,    " Selling Price
            mvg_prs like mbew-verpr,          " Moving Price
            gp_mvp_amt like vbrp-netwr,       " GrossProfit Amount(MVP)
            gp_mvp_pr(6)  type p decimals 2,  "   ,, percentage
          end of itab_out.
    Internal table to write the report output when Mode
    Radiobutton is selected
    data: begin of itab_out2 occurs 0,
            mode(10),
            vbeln like vbrk-vbeln,             " Billing Document Number
            fktyp like vbrk-fktyp,             " Billing Category
            vbtyp like vbrk-vbtyp,             " Sales Doc Category
            fkdat like vbrk-fkdat,             " Billing doc date
            kunag like vbrk-kunag,             " Sold to party
            kunnr like kna1-kunnr,             " Customer
            bukrs like vbrk-bukrs,             " Company Code
            kurrf like vbrk-kurrf,             " Exchange Rate
            waerk like vbrk-waerk,             " Currency
            vrkme like vbrp-vrkme,             " Sales UNit
            posnr like vbrp-posnr,             " Item No
            charg like vbrp-charg,             " Batch Number
            fkimg like vbrp-fkimg,             " Billed quantity
            werks like vbrp-werks,             " Plant
            matnr like vbrp-matnr,             " Material Number
            kdmat like vbap-kdmat,             " Customer Material No
            bil_amt(16)   type p decimals 2,   " Billing Amount
            density(10),                       " density
            sel_prc(16) type p decimals 4,     " Selling Price
            mvg_prs like mbew-verpr,           " Moving Price
            gp_mvp_amt like vbrp-netwr,        " GrossProfit Amount(MVP)
            gp_mvp_pr(6)  type p decimals 2,   "   ,, percentage
          end of itab_out2.
    Internal table to write the report output when Density
    Radiobutton is selected
    data: begin of itab_out3 occurs 0,
            mode(10),
            density(10),
            vbeln like vbrk-vbeln,            " Billing Document Number
            fktyp like vbrk-fktyp,            " Billing Category
            vbtyp like vbrk-vbtyp,            " Sales Doc Category
            fkdat like vbrk-fkdat,            " Billing doc date
            kunag like vbrk-kunag,            " Sold to Party
            kunnr like kna1-kunnr,            " Customer
            bukrs like vbrk-bukrs,            " Company Code
            kurrf like vbrk-kurrf,            " Exchange Rate
            waerk like vbrk-waerk,            " Currency
            vrkme like vbrp-vrkme,            " Sales Unit
            posnr like vbrp-posnr,            " Item Number
            charg like vbrp-charg,            " Batch Number
            fkimg like vbrp-fkimg,            " Billed quantity
            werks like vbrp-werks,            " Plant
            matnr like vbrp-matnr,            " Material Number
            kdmat like vbap-kdmat,            " Customer Material
            bil_amt(16)   type p decimals 2,  " Bill Amount
            sel_prc(16) type p decimals 4,    " Selling Price
            mvg_prs like mbew-verpr,          " Moving Price
            gp_mvp_amt like vbrp-netwr,       " GrossProfit Amount(MVP)
            gp_mvp_pr(6)  type p decimals 2,  "   ,, percentage
          end of itab_out3.
    *-Internal Table to Hold data to be downloaded to file
    data: begin of itab_out1 occurs 0,
            kunag(10),                       " Customer
            vbeln(10),                       " Billing Doc No
            fkdat(10),                       " Bill Date
            posnr(6),                        " Item No
            mode(6),                         " Mode
            density(6),                      " Density
            matnr(18),                       " Material
            charg(10),                       " Batch Number
            fkimg like vbrp-fkimg,           " Billed quantity
            vrkme(4),                        " Sales Unit
            sel_prc(14),                     " Selling Price
            bil_amt(15)  type p decimals 2,  " Billing Amount
            waerk(4),                        " Currency
            mvg_prs(15),                     " Moving Price
            gp_mvp_amt like vbrp-netwr,      " Gross profit Amount(MVP)
            gp_mvp_pr(15),                   "    ,,  percentage
            kdmat(35),                       " Customer Material
          end of itab_out1.
    *Internal Table
    data: begin of fieldnames occurs 0,
            title(25) type c,
            table(5)  type c,
            field(5)  type c,
            type(1)   type c,
          end of fieldnames.
    Declaration Of Variables
    data: w_period like bapi0002_4-fiscal_period,
          w_year   like bapi0002_4-fiscal_year,
          w_date   like bsad-budat,
          w_lin type i.       "No.of lines in Internal Table
    data: t_fkimg             like vbrp-fkimg,
          t_bil_amt(8)        type p decimals 2,
          t_gp_mvp_amt(8)     type p decimals 2,
          t_gr_fkimg          like vbrp-fkimg,
          t_gr_bil_amt(8)     type p decimals 2,
          t_gr_gp_mvp_amt(8)  type p decimals 2,
          t_efkimg            like vbrp-fkimg,
          t_ebil_amt(8)       type p decimals 2,
          t_egp_mvp_amt(8)    type p decimals 2.
    data:f_flg .
                       Select-Options
    selection-screen: begin of block b with frame.
    selection-screen : begin of block b1 with frame title text-001.
    select-options:s_bukrs for t001-bukrs no intervals no-extension
                                                         obligatory,
                   s_vkorg for tvko-vkorg no intervals no-extension,
                   s_vtweg for tvtw-vtweg no intervals no-extension,
                   s_spart for tspa-spart no intervals no-extension,
                   s_werks for t001w-werks no intervals no-extension,
                   s_kunag for kna1-kunnr,
                   s_vbeln for vbuk-vbeln,
                   s_fkart for tvfk-fkart,
                   s_fkdat for vbrk-fkdat obligatory.
    selection-screen begin of line.
    selection-screen comment 1(20) text-008.
    selection-screen end   of line.
    selection-screen begin of line.
    parameters p_cust type c radiobutton group cust.
    selection-screen comment 3(20) text-004 for field p_cust.
    selection-screen end of line.
    selection-screen begin of line.
    parameters p_mode type c radiobutton group cust.
    selection-screen comment 3(20) text-006 for field p_mode.
    selection-screen end of line.
    selection-screen begin of line.
    parameters p_dens type c radiobutton group cust.
    selection-screen comment 3(20) text-007 for field p_dens.
    selection-screen end of line.
    selection-screen: end of block b1.
    selection-screen : begin of block b2 with frame title text-002.
    parameters:  p_dwnlod as checkbox,
                 p_file like rlgrap-filename. " default 'C:\zesdr001'.
    selection-screen: end of block b2.
    selection-screen: end of block b.
    *******At Selection Screen********************************************
    at selection-screen.
    At Selection Screen on Value Request
    at selection-screen on value-request for p_file.
      perform f4_help.
    Checking for the input values of selection screen.
      perform screen_check.
    Top Of Page***************************************************
    top-of-page.
      perform rep_headers.
    *******Start of Selection*********************************************
    start-of-selection.
    Selecting data from the database tables
      perform invoice_selection.
      describe table itab_bill lines w_lin.
      if w_lin = 0.
        message i008.   " No Data Found for the Given Selection Criteria
      else.
    Moving the data records into output internal table
        perform bill_details.
    When Customer Radio button is selected
        if p_cust eq 'X'.
          perform invoice_output_cust.
    When Mode Radio button is selected
        elseif p_mode eq 'X'.
          perform invoice_output_mode.
    When density Radio button is selected
        elseif p_dens eq 'X'.
          perform invoice_output_dens.
        endif.
      endif.
    *******End of Selection***********************************************
    end-of-selection.
      perform init_fieldnames.
      if p_dwnlod = 'X'.
        perform read_data_for_dowlload.
      perform down_load_to_file using p_file.
        perform download_excel using p_file.
      endif.
    *&      Form  screen_check
       Ckecking for Selection Screen fields Validation
    form screen_check.
    Validation of Sales Organization
      clear tvko.
      if not s_vkorg-low is initial.
        select vkorg from tvko up to 1 rows
               into tvko-vkorg
               where vkorg in s_vkorg.
        endselect.
        if sy-subrc ne 0.
          message e009.  " Invalid Sales Organization
        endif.
      endif.
    Validation of Distribution Channel
      clear tvtw.
      if not s_vtweg-low is initial.
        select vtweg from tvtw up to 1 rows
               into tvtw-vtweg
               where vtweg in s_vtweg.
        endselect.
        if sy-subrc ne 0.
          message e010.  " Invalid Distribution Channel
        endif.
      endif.
    Validation of Division
      clear tspa.
      if not s_spart-low is initial.
        select spart from tspa up to 1 rows
               into tspa-spart
               where spart in s_spart.
        endselect.
        if sy-subrc ne 0.
          message e011.  " Invalid Division
        endif.
      endif.
    Validation for company code
      clear t001.
      if not s_bukrs-low is initial.
        select single bukrs from t001
             into t001-bukrs
             where bukrs in s_bukrs.
        if sy-subrc <> 0.
          message e007.   " Enter valid Company Code
        endif.
      endif.
    Validation of billing Document Type
      clear tvfk.
      if not s_fkart is initial.
        select fkart from tvfk up to 1 rows
               into tvfk-fkart
               where fkart in s_fkart.
        endselect.
        if sy-subrc ne 0.
          message e012.  " Invalid Billing Document Type
        endif.
      endif.
    Validation of Billing Document Number
      clear vbuk.
      if not s_vbeln is initial.
        select vbeln from vbuk up to 1 rows
               into vbuk-vbeln
               where vbeln in s_vbeln and
                     vbtyp = 'M'.
        endselect.
        if sy-subrc ne 0.
          message e013.   " Invalid Billing Doc Number
        endif.
      endif.
    Validation of Customer
      clear kna1.
      if not s_kunag is initial.
        select kunnr from kna1 up to 1 rows
               into kna1-kunnr
               where kunnr in s_kunag.
        endselect.
        if sy-subrc ne 0.
          message e014.    " Invalid Customer Number
        endif.
      endif.
    Validation of Plant
      clear t001w.
      if not s_werks is initial.
        select werks from t001w up to 1 rows
               into t001w-werks
               where werks in s_werks.
        endselect.
        if sy-subrc ne 0.
          message e004.    " Invalid Plant Number
        endif.
      endif.
    Validation for File path to download
      if p_dwnlod = 'X'.
        if p_file is initial.
          message e006.  " Enter the Valid file path to Download
        endif.
      endif.
    endform.             "screen_check
          FORM invoice_selection                                        *
    Selecting data from the database tables
    form invoice_selection.
      select
            a~vbeln                   " Billing Doc Number
            a~fktyp                   " Billing Category
            a~vbtyp                   " Sales Doc category
            a~fkdat                   " Billing doc date
            a~fkart                   " Billing doc type
            a~bukrs                   " Company code
            a~kurrf                   " Exchange rate
            a~knumv                   " Condition record Number
            a~waerk                   " Currency
            a~kunag                   " Sold to Party
            b~vrkme                   " Sales Unit
            b~posnr                   " Item Number
            b~charg                   " Batch Number
            b~fkimg                   " Billed quantity
            b~werks                   " Plant
            b~matnr                   " Material Number
            b~netwr                   " Net Value of Bill Doc
            b~wavwr                   " Cost in Doc Currency
            c~kdmat                   " Customer Material
                     into table itab_bill
                     from vbrk as a join vbrp as b
                            on bvbeln = avbeln
                            join vbap as c
                            on baubel = cvbeln and
                               baupos = cposnr
                      where a~vbeln in s_vbeln and
                            a~fkdat in s_fkdat and
                            a~bukrs in s_bukrs and
                            a~vtweg in s_vtweg and
                            a~vkorg in s_vkorg and
                            a~spart in s_spart and
                            a~fkart in s_fkart and
                            b~werks in s_werks and
                            a~kunag in s_kunag and
                            a~sfakn eq ' ' and
                            a~fksto eq ' ' .
    endform .
          FORM bill_details                                             *
    appending data into itab_out internal table
    form bill_details.
      sort itab_bill by vbeln.
      select single waers from t001 into t001-waers
                              where bukrs in s_bukrs.
      data:f_txt1(10),f_txt2(10),f_txt3(10).
      loop at itab_bill.
        itab_out-vbeln   = itab_bill-vbeln.
        itab_out-fktyp   = itab_bill-fktyp.
        itab_out-vbtyp   = itab_bill-vbtyp.
        itab_out-fkdat   = itab_bill-fkdat.
        itab_out-fkart   = itab_bill-fkart.
        itab_out-bukrs   = itab_bill-bukrs.
        itab_out-kurrf   = itab_bill-kurrf.
        itab_out-waerk   = itab_bill-waerk.
        itab_out-kunag   = itab_bill-kunag.
        itab_out-vrkme   = itab_bill-vrkme.
        itab_out-posnr   = itab_bill-posnr.
        itab_out-charg   = itab_bill-charg.
        itab_out-fkimg   = itab_bill-fkimg.
        itab_out-werks   = itab_bill-werks.
        itab_out-matnr   = itab_bill-matnr.
        itab_out-kdmat   = itab_bill-kdmat.
       select single currdec from tcurx into tcurx-currdec
              where currkey eq itab_out-waerk.
        if sy-subrc eq '0' .
          if tcurx-currdec eq '0'.
            itab_bill-netwr = itab_bill-netwr * 100.
            itab_bill-wavwr = itab_bill-wavwr * 100.
          endif.
        endif.
        itab_out-bil_amt = itab_bill-netwr.
        clear : konv.
    Pricing data from KONV table
        select single kbetr kwert kpein from konv into
                                      (konv-kbetr,konv-kwert,konv-kpein)
                                       where knumv = itab_bill-knumv and
                                             kposn = itab_bill-posnr and
                                             kschl eq 'ZSP1' and
                                             krech eq 'C' and
                                             kinak eq ' '.
    Currency conversion
        select single currdec from tcurx into tcurx-currdec
                           where currkey eq itab_out-waerk.
        if sy-subrc eq '0' .
          if tcurx-currdec eq '0'.
            konv-kbetr = konv-kbetr * 100.
          endif.
        endif.
    Unit Price
        itab_out-sel_prc = konv-kbetr.
    Unit Price Calculation
        if not konv-kpein is initial.
          itab_out-sel_prc = itab_out-sel_prc / konv-kpein .
        endif.
    Call Function to get the Period for the given Billing date
    and Company Code
        perform get_period.
    Selecting Material Valuation Data
        clear:mbew.
        if itab_out-fktyp eq 'L'.
          select single
              lfmon lfgja verpr stprs vmver vmstp
                 from mbew
                 into (mbew-lfmon,mbew-lfgja,mbew-verpr,
                       mbew-stprs,mbew-vmver,mbew-vmstp)
                          where matnr = itab_out-matnr
                          and   bwkey = itab_out-werks.
          if mbew-lfmon = w_period and mbew-lfgja = w_year.
            select single currdec from tcurx into tcurx-currdec
                  where currkey eq t001-waers.
            if sy-subrc eq '0' .
              if tcurx-currdec eq '0'.
                mbew-stprs = mbew-stprs * 100.
                mbew-verpr = mbew-verpr * 100.
              endif.
            endif.
            if itab_out-waerk eq t001-waers.
              itab_out-mvg_prs = mbew-verpr  ."/ itab_out-kurrf.
            else.
              itab_out-mvg_prs = mbew-verpr  / itab_out-kurrf.
            endif.
          else.
            clear:mbewh.
            select single
             lfmon lfgja verpr stprs
                from mbewh
                into (mbewh-lfmon,mbewh-lfgja,mbewh-verpr,
                      mbewh-stprs)
                         where matnr = itab_out-matnr
                         and   bwkey = itab_out-werks
                         and   lfmon = w_period
                         and   lfgja = w_year.
            select single currdec from tcurx into tcurx-currdec
                    where currkey eq t001-waers.
            if sy-subrc eq '0' .
              if tcurx-currdec eq '0'.
                mbewh-verpr = mbewh-verpr * 100.
              endif.
            endif.
            if itab_out-waerk eq t001-waers.
              itab_out-mvg_prs = mbewh-verpr ."/ itab_out-kurrf.
            else.
              itab_out-mvg_prs = mbewh-verpr  / itab_out-kurrf.
            endif.
            if itab_out-mvg_prs is initial.
              select single
                      lfmon lfgja verpr stprs vmver vmstp
                         from mbew
                         into (mbew-lfmon,mbew-lfgja,mbew-verpr,
                               mbew-stprs,mbew-vmver,mbew-vmstp)
                                  where matnr = itab_out-matnr
                                  and   bwkey = itab_out-werks.
              select single currdec from tcurx
                 into tcurx-currdec
                 where currkey eq t001-waers.
              if sy-subrc eq '0' .
                if tcurx-currdec eq '0'.
                  mbew-verpr = mbew-verpr * 100.
                endif.
              endif.
              if itab_out-waerk eq t001-waers.
                itab_out-mvg_prs = mbew-verpr  ."/ itab_out-kurrf.
              else.
                itab_out-mvg_prs = mbew-verpr  / itab_out-kurrf.
              endif.
            endif.
          endif.
        endif.
    To find Density and Mode from MARA and T179T tables
        clear :mara,t179t.
        select single prdha from mara
              into mara-prdha
              where matnr = itab_out-matnr.
        select single vtext from t179t
               into t179t-vtext
               where spras = 'EN' and
               prodh = mara-prdha(4).
        split t179t-vtext at ' ' into f_txt1 f_txt2 f_txt3.
        itab_out-mode = f_txt2.
        itab_out-density = f_txt3.
        if not itab_out-mvg_prs is initial.
          if itab_out-fktyp eq 'L'.
            itab_out-gp_mvp_amt = itab_out-bil_amt - itab_out-mvg_prs *
                                                       itab_out-fkimg.
          else.
            itab_out-gp_mvp_amt = '0'.
          endif.
        endif.
        if not itab_out-mvg_prs is initial
           and not itab_out-sel_prc is initial.
          itab_out-gp_mvp_pr = ( itab_out-sel_prc - itab_out-mvg_prs )
                                         / itab_out-sel_prc * 100.
        endif.
        append itab_out.
        clear itab_out.
      endloop.
      loop at itab_out.
        if itab_out-vbtyp eq 'N' or itab_out-vbtyp eq 'O'.
          itab_out-fkimg   = itab_out-fkimg * -1.
          itab_out-sel_prc = itab_out-sel_prc * -1.
          itab_out-bil_amt = itab_out-bil_amt * -1.
          itab_out-mvg_prs = itab_out-mvg_prs * -1.
          itab_out-gp_mvp_amt = itab_out-gp_mvp_amt * -1.
          itab_out-gp_mvp_pr = itab_out-gp_mvp_pr * -1.
    If the bill amount is 0 then the quantity should also be 0.
          if itab_out-bil_amt = 0.
            itab_out-fkimg = 0.
          endif.
    Check if the Bill amount is Credit memo amount, then the gross profit
    should also be the same bill amount irrespecitve of +ve or -ve.
          if itab_out-gp_mvp_amt = 0.
            move: itab_out-bil_amt to itab_out-gp_mvp_amt.
          endif.
          modify itab_out.
          clear itab_out.
        endif.
      endloop.
    endform.
    *&      Form  get_period
    Getting Document Period
    form get_period.
      clear :w_period,w_year,w_date.
      concatenate itab_out-fkdat(4)
                   itab_out-fkdat+4(2)
                   itab_out-fkdat+6(2)
                   into w_date.
      call function 'BAPI_COMPANYCODE_GET_PERIOD'
           exporting
                companycodeid = itab_out-bukrs
                posting_date  = w_date
           importing
                fiscal_year   = w_year
                fiscal_period = w_period.
    endform.                    " get_period
    *&      Form  invoice_output_cust
          Report Output when customer is selected
    form invoice_output_cust.
      write at /1(214) sy-uline.
      sort itab_out  by kunag vbeln fkart posnr fkdat.
      loop at itab_out.
        if f_flg = 'X'.
          format color col_normal intensified off.
          f_flg = ' '.
        else.
          format color col_normal intensified on.
          f_flg = 'X'.
        endif.
        at new kunag.
          read table itab_out index sy-tabix.
        endat.
        write:  /01 sy-vline,  2(10) itab_out-kunag,
                 12 sy-vline, 13(10) itab_out-vbeln,
                 23 sy-vline, 24(6)  itab_out-posnr,
                 30 sy-vline, 31(10) itab_out-fkdat,
                 41 sy-vline, 42(6)  itab_out-mode,
                 48 sy-vline, 49(7)  itab_out-density,
                 56 sy-vline, 57(18) itab_out-matnr,
                 75 sy-vline, 76(10) itab_out-charg,
                 86 sy-vline,
                 87(13) itab_out-fkimg unit itab_out-vrkme no-sign,
                 102(3) itab_out-vrkme,
                105 sy-vline,
                106(14) itab_out-sel_prc currency konv-waers no-sign,
                120 sy-vline,
                121(15) itab_out-bil_amt currency vbrk-waerk no-sign,
                138(3) itab_out-waerk,
                141 sy-vline,
                142(15) itab_out-mvg_prs currency vbrk-waerk no-sign,
                157 sy-vline,
                158(15) itab_out-gp_mvp_amt currency vbrk-waerk no-sign,
                173 sy-vline,174(6)  itab_out-gp_mvp_pr no-sign ,
                180 sy-vline,181(33) itab_out-kdmat,
                214 sy-vline.
        t_fkimg = t_fkimg + itab_out-fkimg.
        t_bil_amt = t_bil_amt + itab_out-bil_amt.
        t_gp_mvp_amt = t_gp_mvp_amt + itab_out-gp_mvp_amt.
        t_gr_fkimg      = t_gr_fkimg         + itab_out-fkimg.
        t_gr_bil_amt    = t_gr_bil_amt       + itab_out-bil_amt.
        t_gr_gp_mvp_amt = t_gr_gp_mvp_amt    + itab_out-gp_mvp_amt.
        at end of kunag.
          format reset.
          format color col_total intensified off.
          write:/1(214) sy-uline.
          write:/01 sy-vline,
                 02 'Sub Total of Customer:'(035), itab_out-kunag,
                 87(13) t_fkimg unit itab_out-vrkme no-sign,
                121(15) t_bil_amt no-sign,
                158(15) t_gp_mvp_amt no-sign,
                214 ' ',
                /1(214)  sy-uline.
          clear: t_fkimg, t_bil_amt, t_gp_mvp_amt.
        endat.
        at last.
          write:/01 sy-vline,
                 02 'Grand Total :'(032),
                 87(13) t_gr_fkimg unit itab_out-vrkme no-sign,
                121(15) t_gr_bil_amt no-sign,
                158(15) t_gr_gp_mvp_amt no-sign,
                214 ' '.
        endat.
        format color off.
      endloop.
      write at /1(214) sy-uline.
    endform.    "invoice_output_cust
    *&      Form  invoice_output_mode
          Report Output
    form invoice_output_mode.
      loop at itab_out.
        move-corresponding itab_out to itab_out2.
        append itab_out2.
        clear: itab_out2.
      endloop.
      write at /1(214) sy-uline.
      sort itab_out2  by mode vbeln posnr fkdat.
      loop at itab_out2.
        if f_flg = 'X'.
          format color col_normal intensified off.
          f_flg = ' '.
        else.
          format color col_normal intensified on.
          f_flg = 'X'.
        endif.
        at new mode.
          read table itab_out2 index sy-tabix.
        endat.
        write: /01 sy-vline,  2(10) itab_out2-kunag,
                12 sy-vline, 13(10) itab_out2-vbeln,
                23 sy-vline, 24(6)  itab_out2-posnr,
                30 sy-vline, 31(10) itab_out2-fkdat,
                41 sy-vline, 42(6)  itab_out2-mode,
                48 sy-vline, 49(7)  itab_out2-density,
                56 sy-vline, 57(18) itab_out2-matnr,
                75 sy-vline, 76(10) itab_out2-charg,
                86 sy-vline,
                87(13) itab_out2-fkimg unit itab_out2-vrkme no-sign,
                102(3) itab_out2-vrkme,
                105 sy-vline,
                106(14) itab_out2-sel_prc currency vbrk-waerk no-sign,
                120 sy-vline,
                121(15) itab_out2-bil_amt currency vbrk-waerk no-sign,
                             138(3)  itab_out2-waerk,
                141 sy-vline,
                142(15) itab_out2-mvg_prs currency vbrk-waerk no-sign,
                157 sy-vline,
                158(15) itab_out2-gp_mvp_amt currency vbrk-waerk no-sign,
                173 sy-vline,174(6)  itab_out2-gp_mvp_pr no-sign,
                180 sy-vline,181(33) itab_out2-kdmat,
                214 sy-vline.
        t_fkimg = t_fkimg + itab_out2-fkimg.
        t_bil_amt = t_bil_amt + itab_out2-bil_amt.
        t_gp_mvp_amt = t_gp_mvp_amt + itab_out2-gp_mvp_amt.
        t_gr_fkimg      = t_gr_fkimg         + itab_out2-fkimg.
        t_gr_bil_amt    = t_gr_bil_amt       + itab_out2-bil_amt.
        t_gr_gp_mvp_amt = t_gr_gp_mvp_amt    + itab_out2-gp_mvp_amt.
        at end of mode.
          format reset.
          format color col_total intensified off.
          write:/1(214) sy-uline.
          write:/01 sy-vline,
                 02 'Sub Total of Mode :'(033), itab_out2-mode,
                 87(13) t_fkimg unit itab_out-vrkme no-sign,
                121(15) t_bil_amt no-sign,
                158(15) t_gp_mvp_amt no-sign,
                214 ' ',
                /1(214)  sy-uline.
          clear: t_fkimg, t_bil_amt, t_gp_mvp_amt.
        endat.
        at last.
          write:/01 sy-vline,
                 02 'Grand Total :'(032),
                 87(13) t_gr_fkimg unit itab_out-vrkme no-sign,
                121(15) t_gr_bil_amt no-sign,
                158(15) t_gr_gp_mvp_amt no-sign,
                214 ' '.
        endat.
        format color off.
      endloop.
      write at /1(214) sy-uline.
    endform.    "invoice_output_mode
    *&      Form  invoice_output_dens
          Report Output
    form invoice_output_dens.
      loop at itab_out.
        move-corresponding itab_out to itab_out3.
        append itab_out3.
        clear: itab_out3.
      endloop.
      write at /1(214) sy-uline.
      sort itab_out3  by mode density vbeln posnr fkdat.
      loop at itab_out3.
        if f_flg = 'X'.
          format color col_normal intensified off.
          f_flg = ' '.
        else.
          format color col_normal intensified on.
          f_flg = 'X'.
        endif.
        at new mode.
        endat.
        at new density.
          read table itab_out3 index sy-tabix.
        endat.
        write:  /01 sy-vline,  2(10) itab_out3-kunag,
                 12 sy-vline, 13(10) itab_out3-vbeln,
                 23 sy-vline, 24(6)  itab_out3-posnr,
                 30 sy-vline, 31(10) itab_out3-fkdat,
                 41 sy-vline, 42(6)  itab_out3-mode,
                 48 sy-vline, 49(7)  itab_out3-density,
                 56 sy-vline, 57(18) itab_out3-matnr,
                 75 sy-vline, 76(10) itab_out3-charg,
                 86 sy-vline,
                 87(13) itab_out3-fkimg unit itab_out3-vrkme no-sign,
                 102(3) itab_out3-vrkme,
                 105 sy-vline,106(14) itab_out3-sel_prc no-sign,
                 120 sy-vline,
                 121(15) itab_out3-bil_amt currency vbrk-waerk no-sign,
                              138(3)  itab_out3-waerk,
                 141 sy-vline,142(15) itab_out3-mvg_prs no-sign
                                      currency vbrk-waerk,
                 157 sy-vline,158(15) itab_out3-gp_mvp_amt no-sign
                                      currency vbrk-waerk,
                 173 sy-vline,174(6)  itab_out3-gp_mvp_pr no-sign,
                 180 sy-vline,181(33) itab_out3-kdmat,
                 214 sy-vline.
        t_efkimg      = t_efkimg      + itab_out3-fkimg.
        t_ebil_amt    = t_ebil_amt    + itab_out3-bil_amt.
        t_egp_mvp_amt = t_egp_mvp_amt + itab_out3-gp_mvp_amt.
        t_fkimg = t_fkimg + itab_out3-fkimg.
        t_bil_amt = t_bil_amt + itab_out3-bil_amt.
        t_gp_mvp_amt = t_gp_mvp_amt + itab_out3-gp_mvp_amt.
        t_gr_fkimg      = t_gr_fkimg         + itab_out3-fkimg.
        t_gr_bil_amt    = t_gr_bil_amt       + itab_out3-bil_amt.
        t_gr_gp_mvp_amt = t_gr_gp_mvp_amt    + itab_out3-gp_mvp_amt.
        at end of density.
          format reset.
          format color col_total intensified off.
          write:/1(214) sy-uline.
          write:/01 sy-vline,
                 02 'Sub Total of Density :'(034), itab_out3-density,
                87(13) t_efkimg unit itab_out-vrkme no-sign,
               121(15) t_ebil_amt currency vbrk-waerk no-sign,
               158(15) t_egp_mvp_amt currency vbrk-waerk no-sign,
               214 ' ',
                /1(214) sy-uline.
          clear: t_efkimg, t_ebil_amt,t_egp_mvp_amt.
        endat.
        at end of mode.
          format reset.
          format color col_total intensified off.
          write:/01 sy-vline,
                 02 'Sub Total of Mode :'(033), itab_out3-mode,
                 87(13) t_fkimg unit itab_out-vrkme no-sign,
                121(15) t_bil_amt no-sign,
                158(15) t_gp_mvp_amt no-sign,
                214 ' ',
                /1(214) sy-uline.
          clear: t_fkimg, t_bil_amt, t_gp_mvp_amt.
        endat.
        at last.
          write:/01 sy-vline,
                 02 'Grand Total :'(032),
                87(13) t_gr_fkimg unit itab_out-vrkme no-sign,
               121(15) t_gr_bil_amt no-sign,
               158(15) t_gr_gp_mvp_amt no-sign,
               214 ' '.
        endat.
        format color off.
      endloop.
      write at /1(214) sy-uline.
    endform.    "invoice_output_dens
    *&      Form  f4_help
          To Get F4 Help to Select File Name
    form f4_help.
      call function 'F4_FILENAME'
           exporting
                program_name  = sy-cprog
                dynpro_number = syst-dynnr
                field_name    = 'P_FILE'
           importing
                file_name     = p_file.
    endform.                                                    " f4_help
    *&      Form  rep_headers
          Report Header
    form rep_headers.
      format color col_heading on.
      format color col_heading on.
      select single butxt from t001 into t001-butxt
                                    where bukrs = s_bukrs-low.
      skip 2.
      write: /2 t001-butxt, 92 'BILLING ANALYSIS'(003),
             190 'Date :'(010),sy-datum.
      write :/2 'Company Code :'(011), s_bukrs-low ,
            85 'Billing Date :'(012) , s_fkdat-low , '-' ,s_fkdat-high ,
            190 'Page :'(013), sy-pagno,
            214 ' '.
      write at /1(214) sy-uline.
      write: /1 sy-vline,  2(10) 'Customer'(004) centered,
             12 sy-vline, 13(10) 'Billing'(009) centered,
             23 sy-vline, 24(6)  'Billing'(009) centered,
             30 sy-vline, 31(10) 'Billing'(009) centered,
             41 sy-vline, 42(6)  'Mode'(006) centered,
             48 sy-vline, 49(7)  'Density'(014) centered,
             56 sy-vline, 57(18) 'Material'(015) centered,
             75 sy-vline, 76(10) 'Batch'(016) centered,
             86 sy-vline, 87(13) 'Quantity'(017) centered,102(3) 'UOM'(027),
             105 sy-vline, 106(14) 'Selling'(018) centered ,
             120 sy-vline, 121(15) 'Billing'(009) centered,
                           138(3) 'Cur'(028),
             141 sy-vline, 142(15) 'Mvg.Avg.Price'(020) centered,
             157 sy-vline, 158(22) 'Gross Profit(MVP)'(022) centered,
             180 sy-vline, 181(33) 'Customer Material'(023) centered,
             214 sy-vline.
      write: /1 sy-vline,  2(10) 'Code'(024) centered,
             12 sy-vline, 13(10) 'Document'(025) centered,
             23 sy-vline, 24(6)  'Item'(026) centered,
             30 sy-vline, 31(10) 'Date'(036) centered,
             41 sy-vline,
             48 sy-vline,
             56 sy-vline,
             75 sy-vline,
             86 sy-vline,
            105 sy-vline, 106(14) 'Price'(030) centered ,
            120 sy-vline, 121(15) 'Amount'(031) centered,
            141 sy-vline, 142(15) '(per Unit)'(019) centered,
            157 sy-vline, 158(15) 'Amount'(031) centered,
            173 sy-vline, 174(6) ' % '(029) centered,
            180 sy-vline,
            214 sy-vline.
      format color off.
    endform.                    " rep_headers
    *&      Form  init_fieldnames
    Initialise all the fields to download in Excel Data File
    form init_fieldnames.
      perform append_fieldname using text-004 'itab_out1'
                                     'KUNAG'    'X'.
      perform append_fieldname using text-037 'itab_out1'
                                     'VBELN'   'X'.
      perform append_fieldname using text-036 'itab_out1'
                                     'FKDAT'  'X'.
      perform append_fieldname using text-038 'itab_out1'
                                     'POSNR'    'X'.
      perform append_fieldname using text-006 'itab_out1'
                                     'MODE' 'X'.
      perform append_fieldname using text-014 'itab_out1'
                                     'DENSITY' 'X'.
      perform append_fieldname using text-015 'itab_out1'
                                     'MATNR'    'X'.
      perform append_fieldname using text-016 'itab_out1'
                                     'CHARG' 'X'.
      perform append_fieldname using text-017 'itab_out1'
                                     'FKIMG'    'X'.
      perform append_fieldname using text-039 'itab_out1'
                                     'VRKME' 'X'.
      perform append_fieldname using text-040 'itab_out1'
                                     'SEL_PRC' 'X'.
      perform append_fieldname using text-041 'itab_out1'
                                     'BIL_AMT' 'X'.
      perform append_fieldname using text-028 'itab_out1'
                                     'WAERK' 'X'.
      perform append_fieldname using text-020 'itab_out1'
                                     'MVG_PRS' 'X'.
      perform append_fieldname using text-044 'itab_out1'
                                     'GP_MVP_AMT' 'X'.
      perform append_fieldname using text-045 'itab_out1'
                                     'GP_MVP_PR' 'X'.
      perform append_fieldname using text-023 'itab_out1'
                                     'KDMAT'         'X'.
    endform.
    *&      Form  append_fieldname
    Appending field Names
    form append_fieldname using p_title p_table p_field p_type.
      clear: fieldnames.
      fieldnames-title = p_title.
      fieldnames-table = p_table.
     

  • Report output "MCTA"

    Hi guys,
    I am trying to take the customer wise sales report using Tcode "MCTA" .But I see that  the output  of this reports doesnt show few customer .Where as those customer are see int he Trial balace in FI and also in the out put of te report "S_ALR_87012186"
    Can any one help to tell what can be the exact issue for few customers not been displayed in the Report "MCTA".
    I have checked the customer Master data and it seems to be OK.
    Rgds.

    Hi,
    Report "MCTA" is a SAP sales information System report (SIS). In order to generate an output for this report, system has to first fill data in to info structures. If you do not have data in the info structure, system will not be able to generate an output.
    Based on below "Statistical Groups", system fill sales data in to relevant info structures.
    - Statistical groups for customers -> Assigned in the customer master Sales area data / Sales tab - Field "Cust.Stats.Grp"
    - Statistics Groups for Material -> Assigned to each material in sales 2 view of the material master
    - Statistics Groups for Sales Document -> Assigned to sales document type in the config.
    - Statistics Groups to each Sales Item category ->Assigned to Item category in the config
    Since you're saying only few customers do not get any output in "MCTA", I would recommend you to check those customer masters for Sales area data / Sales tab - Field "Cust.Stats.Grp". Please compare this field value with customers who get an output in the report.
    I think below link will be very useful for you to see whether there is anything missing in your SIS configuration.
    [SIS|http://learnsaptips.blogspot.com/2010/08/how-to-create-activate-sales.html]
    best regards,
    Rahal

  • Output of Purchase order Configured FAX as medium..

    Hi All,
    One of Purchase order is configured with communication medium as FAX and output type as NEU.How to see the output?
    Thanks

    hi
    Output of Purchase Order
    1. Condition Table
    SPRO > Material Management> Purchasing -> Message -> Output Control->Condition Tables->Define Condition Table for Purchase Order
    Select:
    Purchasing Doc. Type, Purch. Organization, Vendor
    2. Access Sequences
    SPRO -> Material Management-> Purchasing -> Message -> Output Control->Access Sequences->Define Condition Table for Purchase Order
    3. Message Type
    SPRO -> Material Management-> Purchasing -> Message -> Output Control->Message Types->Define Message Type for Purchase Order
    *4. Message Determination Schemas*
    4.1. Message Determination Schemas
    SPRO -> Material Management-> Purchasing -> Message -> Output Control->Message Schema->Define Message Schema for Purchase Order-> Maintain Message Determination Schema
    4.2. Assign Schema to Purchase Order
    SPRO -> Material Management-> Purchasing -> Message -> Output Control->Message Schema->Define Message Schema for Purchase Order-> Assign Schema to Purchase Order
    5. Partner Roles per Message Type
    SPRO -> Material Management-> Purchasing -> Message -> Output Control-> Partner Roles per Message Type ->Define Partner Role for Purchase Order
    6. Condition Record
    Navigation Path: SAP Menu-> Logistics -> Material Management -> Purchasing-> Master data-
    here all above steps u can do from transacton NACE
    now when u create po in the messages select out put as FAX and the take out put
    http://www.scribd.com/doc/7839934/Faxing-a-Purchase-Order
    regards
    KI
    Edited by: SAP Learner on Apr 17, 2009 12:15 PM

Maybe you are looking for

  • Unable to connect wireless print server while using wireless modem to ISP

    Unable to connect an HP Laserjet 1320 thru the JetDirect ew2400 External Print Server to an imac G5 that uses the 2WIRE352 modem for ISP access thru ATT. Either the ISP is connected and works, or the printer works but no internet access. HP (after 1h

  • Adobe Bridge CC im Hintergrund starten

    Guten Tag zusammen Ich habe vor kurzem ein Upgrade auf Photoshop CC und Bridge CC gemacht. Auch hier wollte ich, wie vorher bei CS5, wieder die Bridge im Hintergrund laufen lassen, damit ich in PS die MiniBridge verwenden kann. Also habe ich in den V

  • MDMP Unicode Conversion problem during ECC upgrade

    hi Experts, I met a problem when upgrade from 4.6c to ecc 6. in 4.6c, some key users made some chinese written entries in table field while he/she was logon as English, so, the language field in this entry is "EN" although the actual language was wri

  • Help! Thumbnail + files lose Sharpening done in Camera Raw

    I sharpen an image in Camera Raw... Looks great. I save it as a JPG to my ext HD. I open and thumbnail previews and file lose the sharpening I applied. Looks terrible. Reinstalled whole Design Premium. Didn't work. Thanks for any answers!

  • Skype continues to ask for a new app, despite installation !?

    Skype blijft vragen om een nieuwe app, ondanks installatie!? Onlangs kreeg ik een aankondiging dat het Skype zou komen met een nieuwe app en dat deze de oude zou moeten vervangen. Inmiddels heb ik deze app geïnstalleerd en gebruikt, maar elke keer wa