2014 Mar 28 11:09 AM
i have sorted the internal table by ascending date_field
if i give the date in selection options as 25.02.2014 to 25.03.2014..
It is printed as 01.03.2014
.to
.
24.03.2014
from next line it is printed as 25.02.2014
25.03.2014
26.02.2014
26.03.2014
How to rectify this issue...
i need to display it as 25.02.2014 to 25.03.2014 by ascending
2014 Mar 28 11:17 AM
Hi Vishwaroop,
Can you please post your code here to let us know which technique you are following and where exactly is the problem.
Regards,
Rachna
2014 Mar 28 11:20 AM
Hi,
I would like to see your code. Could you paste it here?
Regards
2014 Mar 28 11:22 AM
SORT lT_S1 DESCENDING BY MATNR WERKS SPTAG.
LOOP AT lt_S1 INTO ls_S1.
ASSIGN COMPONENT 'WERKS' OF STRUCTURE <DYNWA> TO <L_FIELD>.
<L_FIELD> = ls_S1-WERKS.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <DYNWA> TO <L_FIELD>.
<L_FIELD> = ls_S1-MATNR.
ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <DYNWA> TO <L_FIELD>.
READ TABLE lt_MAKT INTO ls_MAKT WITH KEY MATNR = LS_S1-MATNR.
IF SY-SUBRC EQ 0.
<L_FIELD> = LS_MAKT-MAKTX.
ENDIF.
ASSIGN COMPONENT 'BASME' OF STRUCTURE <DYNWA> TO <L_FIELD>.
<L_FIELD> = ls_S1-BASME.
CALCDAT = LS_S1-SPTAG.
CONCATENATE CALCDAT+6(2) '.' CALCDAT+4(2) '.' CALCDAT(4) INTO g_SPTAG.
ASSIGN COMPONENT 'SPTAG' OF STRUCTURE <DYNWA> TO <L_FIELD>.
<L_FIELD> = g_SPTAG.
ASSIGN COMPONENT 'MZUBB' OF STRUCTURE <DYNWA> TO <L_FIELD>.
<L_FIELD> = ls_S1-MZUBB.
ASSIGN COMPONENT 'MAGBB' OF STRUCTURE <DYNWA> TO <L_FIELD>.
<L_FIELD> = ls_S1-MAGBB.
CALCDAT = LS_S1-SPTAG.
CALCDAT = CALCDAT - 1.
CONCATENATE CALCDAT+6(2) '.' CALCDAT+4(2) '.' CALCDAT(4) INTO G_SPTAG.
ASSIGN COMPONENT 'OPEN_STOCK' OF STRUCTURE <DYNWA> TO <L_FIELD>.
IF LS_S1-SPTAG EQ TODAY1.
READ TABLE LT_MBEW INTO LS_MBEW WITH KEY MATNR = LS_S1-MATNR BWKEY = LS_S1-WERKS.
IF SY-SUBRC EQ 0.
OPEN = LS_MBEW-LBKUM + LS_S1-MAGBB - LS_S1-MZUBB.
<L_FIELD> = OPEN.
ENDIF.
ELSE.
OPEN = OPEN + LS_S1-MAGBB - LS_S1-MZUBB.
<L_FIELD> = OPEN.
ENDIF.
CALCDAT = LS_S1-SPTAG.
CALCDAT = CALCDAT - 1.
CONCATENATE CALCDAT+6(2) '.' CALCDAT+4(2) '.' CALCDAT(4) INTO G_SPTAG.
ASSIGN COMPONENT 'CLOSE_STOCK' OF STRUCTURE <DYNWA> TO <L_FIELD>.
IF LS_S1-SPTAG EQ TODAY1.
READ TABLE LT_MBEW INTO LS_MBEW WITH KEY MATNR = LS_S1-MATNR BWKEY = LS_S1-WERKS.
IF SY-SUBRC EQ 0.
CLOS = OPEN - LS_S1-MAGBB + LS_S1-MZUBB.
<L_FIELD> = CLOS.
ENDIF.
ELSE.
CLOS = OPEN - LS_S1-MAGBB + LS_S1-MZUBB.
<L_FIELD> = CLOS.
ENDIF.
APPEND <DYNWA> TO <DYNTABLE>.
CLEAR: <DYNWA>.
endloop.
SORT <DYNTABLE> ASCENDING. ( here i gets the problem)
endmethod.
2014 Mar 28 11:48 AM
Hi Prathap,
sort <<DYNTABLE> ASCENDING by date_field , make sure that length and data type of it and see how is the format like 'YYYYMMDD' or 'DDMMYYYY'
Can you try declaring the date field as below
data: date_field type sy-datum.
Thanks,
Siva
2014 Mar 28 12:09 PM
Hi,
Keep one more field in your internal table where you can keep the date in the format - YYYYMMDD or DDMMYYYY without dot (.) and sort the table based on this field.
It should work hopefully.
Regards,
Munesh.
2014 Mar 28 11:25 AM
Make sure that you are declaring the variable as type d instead of type c. Do not refer to your field as Character type variable.
Regards
2014 Mar 28 11:26 AM
2014 Mar 28 11:29 AM
But you are assigning the value of G_SPTAG to field symbol which is type c variable. Please check this again.
Regards
2014 Mar 28 11:37 AM
Yes Sorry i gave it as type c...but if i give it as type d also am getting the same problem
2014 Mar 28 11:38 AM
Hi Vishwaroop,
You try to change your line "SORT <DYNTABLE> ASCENDING. ( here i gets the problem)"
for this:
SORT <DYNTABLE> ASCENDING BY ('SPTAG').
Regards.
2014 Mar 28 11:42 AM
2014 Mar 28 11:52 AM
2014 Mar 28 12:02 PM
DATA: lv_data TYPE dats.
CONCATENATE calcdat(4) calcdat+4(2) calcdat+6(2) INTO lv_data.
* ...
<l_field> = lv_data.
" instead of
* CONCATENATE CALCDAT+6(2) '.' CALCDAT+4(2) '.' CALCDAT(4) INTO G_SPTAG.
2014 Mar 28 12:04 PM
2014 Mar 28 12:11 PM
Prathap,
Your G_SPTAG is an string and your assigning those value to some other value ( date_field ) which you have declared it as data type 'C' but now you changed to 'D' right ?
2014 Mar 28 12:32 PM
Hi Vishwaroop,
Take the date into the internal table having the numeric type of field and then take data in format of YYYYMMDD and sort it and use it as per your requirement.
As I think your date is available iin format DDMMYYYY..
Many Thanks / Himanshu Gupta