Skip to Content
author's profile photo Former Member
Former Member

HELP WITH SELECTION SCREENS

Dear All,

I am new to SAP(ABAP) have been given this assignment sort of ....plz help

1. Write a program to fetch all the sales orders and line items with in a data range.

Selection screen fields: Sales Order Number

Document type

Sales order date.

To display in the output report should contain following fields:

1. Sales Order number

2. item number

3. net price

4. net value

5. document type

Use Tables :vbak and vbap.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 04, 2007 at 07:27 AM
    tables: vbap,vbak.
    select-options: s_VBELN for vbap-vbeln,
                    s_AUART for vbak-auart,
                    s_AUDAT for vbak-audat.
                    
      data:begin of itab occurs 0,
        vbeln like vbap-vbeln,
        posnr like vbap-posnr,
        netwr like vbap-netwr,
        netpr like vbap-netpr,
        auart like vbak-auart,
       end of itab.
    select vbap~vbeln vbap~posnr vbap~netwr vbap~netpr vbak~auart
               into table itab from vbap inner join vbak
               on vbap~vbeln = vbak~vbeln
               where vbap~vbeln in s_vbeln
                and vbak~auart in s_auart
                and vbak~audat in s_audat.
    
    loop at itab.
    write:itab-vbeln,itab-posnr, itab-netwr,itab-netpr,itab-auart.
    endloop.
     
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 04, 2007 at 07:12 AM

    for the selection screen, you can define the sales order number as parameter (single value) or select-option (range) :

    parameters: p_vbeln type vbak-vbeln.

    or

    data: wa_vbak type vbak.

    select-options: s_vbeln for wa_vbak-vbeln.

    get data:

    select * from vbak where vbeln eq p_vbeln.

    or

    select * from vbak where vbeln in s_vbeln.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 04, 2007 at 07:13 AM

    hi

    u can use select-options for sales order number and date

    and parameters for document type.

    vbak is for header data...

    and vbap is for item data.

    based on the key field in both tables ie sales order number v can retrieve the details

    store it in an internal table

    and display them by looping at that internal table...

    hope this helps....

    else if u want code...let meknow

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 04, 2007 at 07:21 AM

    select vbeln from vbak where vbeln = p_vbeln

    auart = p_auart

    erdat = p_erdat.

    select vbapvbeln vbapposex vbapnetpr vbapnetwr vbak~auart into i_output

    from vbap inner join vbak

    on vbakvbeln = vbapvbeln.

    Put atll the five fields that you have to display as output in the output internal table i_output

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 04, 2007 at 08:01 AM

    Hi,

    Try this out.

    REPORT yjjtest MESSAGE-ID zm.
    
    TABLES: vbap, vbak.
    DATA: BEGIN OF i_output OCCURS 0,
                 vbeln LIKE vbap-vbeln,
                 posnr LIKE vbap-posnr,
                 netwr LIKE vbap-netwr,
                 netpr LIKE vbap-netpr,
                 auart LIKE vbak-auart,
               END OF i_output.
    
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    " text-001 as Selection
    SELECT-OPTIONS: s_vbeln  FOR vbap-vbeln,
                    s_auart  FOR vbak-auart ,
                    s_audat  FOR vbak-audat.
    SELECTION-SCREEN END OF BLOCK blk1.
    
    START-OF-SELECTION.
    
      SELECT a~vbeln
                    a~posnr
                    a~netwr
                    a~netpr
                    b~auart
                    INTO TABLE i_output
                    FROM vbap AS a
                    INNER JOIN vbak AS b
                    ON a~vbeln = b~vbeln
                    WHERE    a~vbeln IN s_vbeln
                    AND      b~auart IN s_auart
                    AND      b~audat IN s_audat.
      IF sy-subrc NE 0.
      MESSAGE e000 WITH text-002. " No data found for the selection criteria
      ENDIF.
    
      WRITE:/  'Program to fetch all the sales orders and line items'.
      ULINE.
      WRITE:/001 'Sales Order number',
             012 'Item Number',
             025 'Net Price',
             050 'Net Value',
             070 'Document Type'.
      ULINE.
    
      LOOP AT i_output.
        WRITE:/001 i_output-vbeln,
               012 i_output-posnr,
               025 i_output-netwr,
               050 i_output-netpr,
               070 i_output-auart.
        CLEAR i_output.
      ENDLOOP. 

    Hope this solves ur query.

    Sample output

    TEST Program

    Program to fetch all the sales orders and line items

    Sales OrderItem Number Net Price Net Value Document Type

    10000000 000010 0.00 0.00 ZNOR

    10000000 000020 0.00 0.00 ZNOR

    10000006 000010 0.00 0.00 ZNOR

    10000007 000060 0.00 0.00 ZERO

    10000007 000020 0.00 0.00 ZERO

    10000007 000050 0.00 0.00 ZERO

    10000007 000040 0.00 0.00 ZERO

    10000007 000030 0.00 0.00 ZERO

    10000007 000010 0.00 0.00 ZERO

    10000008 000010 13,825.35 3,675.00 ZERO

    10000009 000010 0.00 0.00 ZERO

    10000010 000010 47,002.06 2,637.60 ZERO

    10000011 000010 0.00 0.00 ZERO

    10000012 000010 36,193.40 1,522.01 ZERO

    10000014 000010 0.00 0.00 ZERO

    10000015 000050 0.00 0.00 ZERO

    10000015 000010 0.00 0.00 ZERO

    10000015 000020 0.00 0.00 ZERO

    Please reward points and clos ethe thread.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 05, 2007 at 01:12 PM

    Please reward poinst and mark the thread closed.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.