2015 Aug 12 4:36 AM
Hello Experts,
I am facing issue with date is initial.
Actually I am trying to do transfer posting using IDOCs. If the posting date is initial then I am trying to assign system date is default but my 'if condition is not working'
lw_seg_head = IDOC_DATA-sdata.
MOVE-CORRESPONDING lw_seg_head to lw_gm_head.
if lw_gm_head-PSTNG_DATE is INITIAL.
lw_gm_head-PSTNG_DATE = sy-datum.
endif.
Please advise.
Hello Experts,
I am facing issue with date is initial.
Actually I am trying to do transfer posting using IDOCs. If the posting date is initial then I am trying to assign system date is default but my 'if condition is not working'
lw_seg_head = IDOC_DATA-sdata.
MOVE-CORRESPONDING lw_seg_head to lw_gm_head.
if lw_gm_head-PSTNG_DATE is INITIAL.
lw_gm_head-PSTNG_DATE = sy-datum.
endif.
Please advise.
2015 Aug 12 4:58 AM
Hi Vada,
What is the date type of field lw_gm_head-PSTNG_DATE.
Is it declared as type sy-datum or char. Declare it as sy-datum If it is not declared .
Thanks
-Learner
2015 Aug 12 5:30 AM
Hello,
Did you tried searching SCN before posting this question? I would suggest to read first.
To answer your question, please refer below SCN threads. There could be many other threads on same topics.
https://scn.sap.com/thread/950883
Hope this helps and let us know if this is not something you were looking for.
Thanks,
Rahul
2015 Aug 12 5:32 AM
Hi,
try to define the PSTNG_DATE as sy-datum or sdate.
if lw_gm_head-PSTNG_DATE is INITIAL
or lw_gm_head-PSTNG_DATE = '00000000'.
lw_gm_head-PSTNG_DATE = sy-datum.
endif.
Regerads
Ibr
2015 Aug 12 5:39 AM
Hi,
If you declared posting date as type sy-datum,Then use below condition.
lw_seg_head = IDOC_DATA-sdata.
MOVE-CORRESPONDING lw_seg_head to lw_gm_head.
if lw_gm_head-PSTNG_DATE = '00000000'.
lw_gm_head-PSTNG_DATE = sy-datum.
endif.
Hope this will help you.
Thanks
KH
2015 Aug 12 6:36 AM
Hi,
That to me indicates - you have assigned to lw_gm_head-PSTNG_DATE a value that is not initial (SPACE for example). If the field type is 'date' then the initial value for that type is '00000000'.
If you want to do programming, you should really be able to solve this kind of problems on your own...
cheers
Jānis
2015 Aug 12 8:35 AM
Hi!
Since date field is never empty, it contains only zeros. You can use:
lw_seg_head = IDOC_DATA-sdata.
MOVE-CORRESPONDING lw_seg_head to lw_gm_head.
if lw_gm_head-PSTNG_DATE EQ '00000000'.
lw_gm_head-PSTNG_DATE = sy-datum.
endif.
or
lw_seg_head = IDOC_DATA-sdata.
MOVE-CORRESPONDING lw_seg_head to lw_gm_head.
if lw_gm_head-PSTNG_DATE CO '0'. "Contains only zeros
lw_gm_head-PSTNG_DATE = sy-datum.
endif.
Greetings
Bartłomiej
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |