Application Development and Automation 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: 
Read only

how to select the data in the same table for diff dates in selection-screen

Former Member
0 Likes
1,007

i would like to select the data for two dates selection and would like to comapre them in the output for basic list.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_werks TYPE s997-werks obligatory.

SELECT-OPTIONS: s_matnr FOR s997-matnr, " Material Number

s_mvgr1 FOR s997-mvgr1, " Material Group 1

s_mvgr2 FOR s997-mvgr2, " Material Group 2

s_mvgr3 FOR s997-mvgr3, " Material Group 3

s_vkorg FOR s997-vkorg, " Sales Organization

s_vtweg FOR s997-vtweg, " Distribution Channel

s_pkunag FOR s997-pkunag."Sold to Party

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

SELECT-OPTIONS: s_sptag FOR s997-sptag obligatory, " Date 1

s_sptag1 FOR s997-sptag obligatory. " Date 2

SELECTION-SCREEN END OF BLOCK b2.

as selection screen can any body suggest how to select them as it should be displayed at end of city ort01.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
948

Hi KKK ,

i think u are trying to compare current data with history data.

u can do one thing.

1.First get the data for Current date ( date 1 ) and divid this data into Months/dates.

in this case u can make use of <b>MM_ARRANG_SPMON_RANGE</b>to divid into Months Format

like this i given data1 = 01.2005 - 02.2005.

then get the data for this range 01-02

and divid this data like this

<b>01 02

100KG 200 KG</b>

2.get the data for date2 = 01.2004-02.2004

then get the data for this range 01-02

and divid this data like this

<b>01 02

120KG 220 KG</b>

finally put into o/p screen like this

01/2004 01/2005  02/2004  02/2005
120       100     220      200

my sugg. is check the std.Sap programs which are avail. in Tcode MCSI.

Regards

Prabhu

i would like to select the data for two dates selection and would like to comapre them in the output for basic list.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_werks TYPE s997-werks obligatory.

SELECT-OPTIONS: s_matnr FOR s997-matnr, " Material Number

s_mvgr1 FOR s997-mvgr1, " Material Group 1

s_mvgr2 FOR s997-mvgr2, " Material Group 2

s_mvgr3 FOR s997-mvgr3, " Material Group 3

s_vkorg FOR s997-vkorg, " Sales Organization

s_vtweg FOR s997-vtweg, " Distribution Channel

s_pkunag FOR s997-pkunag."Sold to Party

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

SELECT-OPTIONS: s_sptag FOR s997-sptag obligatory, " Date 1

s_sptag1 FOR s997-sptag obligatory. " Date 2

SELECTION-SCREEN END OF BLOCK b2.

as selection screen can any body suggest how to select them as it should be displayed at end of city ort01.

7 REPLIES 7
Read only

Former Member
0 Likes
949

Hi KKK ,

i think u are trying to compare current data with history data.

u can do one thing.

1.First get the data for Current date ( date 1 ) and divid this data into Months/dates.

in this case u can make use of <b>MM_ARRANG_SPMON_RANGE</b>to divid into Months Format

like this i given data1 = 01.2005 - 02.2005.

then get the data for this range 01-02

and divid this data like this

<b>01 02

100KG 200 KG</b>

2.get the data for date2 = 01.2004-02.2004

then get the data for this range 01-02

and divid this data like this

<b>01 02

120KG 220 KG</b>

finally put into o/p screen like this

01/2004 01/2005  02/2004  02/2005
120       100     220      200

my sugg. is check the std.Sap programs which are avail. in Tcode MCSI.

Regards

Prabhu

Read only

Former Member
0 Likes
948

Hi

One way to extract the data is...

      • Make the two dates as PARAMETERS instead of Select-Options

      • Declare an internal table with the fields required

select <fields> into table it_tab

from s997

where ( sptag = p_sptag1

OR sptag = p_sptag2 )

and " other conditions.

Now that you have the records for two dates, you can

manipulate as per your requirement.

Kind Regards

Eswar

Read only

Former Member
0 Likes
948

actually user has to select as per his combiation of two diff dates and for that i have to use the select-options for date1 and date2. so please can any body suggest me how to proceed, thanks in advance.

Read only

0 Likes
948

Hi Kalyan,

You cannot impose this dates comparision in the select statement what you can do is select the data first without dates and then loop the table to check for your dates comparision.

Check this PSEUDO Code.


*--

  SELECT EKKO~EBELN EKKO~EKGRP EKKO~AEDAT
         EKKO~KDATB EKKO~KDATE EKKO~LIFNR
         EKPO~EBELP EKPO~WERKS EKPO~MATKL
         EKPO~TXZ01 EKPO~NETPR LFA1~NAME1
         INTO CORRESPONDING FIELDS OF TABLE T_DATA
         FROM EKKO JOIN EKPO
         ON EKKO~EBELN = EKPO~EBELN
         JOIN LFA1
         ON EKKO~LIFNR = LFA1~LIFNR
         WHERE EKKO~BSTYP = C_BSTYP
         AND   EKKO~BSART = C_BSART
         AND   EKPO~PSTYP = C_PSTYP
         AND   EKPO~WERKS IN S_WERKS.
*--Process data
  DATA: WAL_OUTPUT TYPE TYPE_DATA.
  FIELD-SYMBOLS: <L_DATA> TYPE TYPE_DATA.
*Sort Input dates
  SORT S_DATE.
  SORT T_OUTPUT BY EBELN EBELP.

  IF NOT T_DATA IS INITIAL.
<b>    LOOP AT S_DATE.
      LOOP AT T_DATA ASSIGNING <L_DATA>
           WHERE ( KDATB <= S_DATE-LOW AND
                   KDATE >= S_DATE-LOW ).</b>
*--Process for Valid on Dates
        READ TABLE T_OUTPUT TRANSPORTING NO FIELDS
                        WITH KEY EBELN = <L_DATA>-EBELN
                                 EBELP = <L_DATA>-EBELP
                                 BINARY SEARCH.
        IF SY-SUBRC <> 0 .
          MOVE-CORRESPONDING <L_DATA> TO WAL_OUTPUT.
          APPEND WAL_OUTPUT TO T_OUTPUT.
        ELSE.
          EXIT.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
  ENDIF.

Regards,

Raghav

Read only

Former Member
0 Likes
948

Hi Kalyan,

use Select-Options statement to select data between two dates

~John

Read only

Former Member
0 Likes
948

Kalyan,

first select data with first s_option into an itab.

nxt select data again with second s_option into jtab.

now u have data in two itabs. u can manipulate the data for as per ur req.

>> Anyhow user will have to give the values at selection-screen ..know...

Rgds,

Praneeth

Read only

Former Member
0 Likes
948

Hi,

I am not very clear about what is required but if for 2 different date selections you want to get data in same internal table then it's very simple.

make a range.

Ranges: ra_date.

Append all the data of the select-options into the range.

In the selection from the DB table in where condition

use where <date_field name> IN ra_date.

Hope this helps

Regards

Nishant