2007 May 18 7:23 AM
Hi Gurus,
In the selection screen I am having a select-option for document type.
I will give 4 types of data types in the selection screen.
In the program I have to move data to different internal tables according to document types.
Here the code goes like this
S_doc_type is document type contains RE, KR, and KG.
IF NOT s_doc_ty IS INITIAL.
LOOP AT gi_bkpf.
IF gi_bkpf-blart EQ gc_re AND
s_doc_ty CO gc_re.
APPEND gi_bkpf TO gi_bkpf_re.
ENDIF.
IF gi_bkpf-blart EQ gc_kr AND
s_doc_ty CO gc_kr.
APPEND gi_bkpf TO gi_bkpf_kr.
ENDIF.
IF gi_bkpf-blart EQ gc_kg AND
s_doc_ty CO gc_kg.
APPEND gi_bkpf TO gi_bkpf_kg.
ENDIF.
ENDLOOP.
endif.
My question is I will give only RE doc type in selection screen so that only this type should be appended and rest should be omitted for differnt document types.
Please let me can i use this kind of code to seperate.
Mac
2007 May 18 7:28 AM
Hi
just use IN parameter it will take care, whatever you enter on selection screen
LOOP AT gi_bkpf.
IF gi_bkpf-blart <b>IN S_BLART.</b>
APPEND gi_bkpf TO gi_bkpf_re.
ENDIF.
Reward points if useful
Regards
Anji
2007 May 18 7:28 AM
Hi
just use IN parameter it will take care, whatever you enter on selection screen
LOOP AT gi_bkpf.
IF gi_bkpf-blart <b>IN S_BLART.</b>
APPEND gi_bkpf TO gi_bkpf_re.
ENDIF.
Reward points if useful
Regards
Anji
2007 May 18 7:30 AM
Hi,
Modify ur code as follows.
LOOP AT gi_bkpf.
IF gi_bkpf-blart EQ gc_re.
READ TABLE s_doc_ty
TRANSPORTING NO FIELDS
WITH KEY low = gi_bkpf-blart.
IF sy-subrc = 0.
APPEND gi_bkpf TO gi_bkpf_re.
ENDIF.
ENDIF.
IF gi_bkpf-blart EQ gc_kr.
READ TABLE s_doc_ty
TRANSPORTING NO FIELDS
WITH KEY low = gi_bkpf-blart.
IF sy-subrc = 0.
APPEND gi_bkpf TO gi_bkpf_kr.
ENDIF.
ENDIF.
IF gi_bkpf-blart EQ gc_kg.
READ TABLE s_doc_ty
TRANSPORTING NO FIELDS
WITH KEY low = gi_bkpf-blart.
IF sy-subrc = 0.
APPEND gi_bkpf TO gi_bkpf_kg.
ENDIF.
ENDIF.
ENDLOOP.
In this case, u r reading the select option for the corresponding value of document type and then only append to respective internal table.
Regards,
Ranjit Thakur.
<b>Please Mark The Helpful Answer.</b>
2007 May 18 7:32 AM
Hi,
IF NOT s_doc_ty IS INITIAL.
LOOP AT gi_bkpf.
IF gi_bkpf-blart EQ gc_re AND
s_doc_ty IN gc_re.
APPEND gi_bkpf TO gi_bkpf_re.
ENDIF.
IF gi_bkpf-blart EQ gc_kr AND
s_doc_ty IN gc_kr.
APPEND gi_bkpf TO gi_bkpf_kr.
ENDIF.
IF gi_bkpf-blart EQ gc_kg AND
s_doc_ty IN gc_kg.
APPEND gi_bkpf TO gi_bkpf_kg.
ENDIF.
ENDLOOP.
endif.
2007 May 18 7:38 AM
Hi Mac,
With some little modification to your code,you can safely use your own code to get the results as follows -
IF NOT s_doc_ty IS INITIAL.
LOOP AT gi_bkpf WHERE ( ( BLART EQ GC_RE ) OR
( BLART EQ GC_KR ) OR
( BLART EQ GC_KG ) ).
IF gi_bkpf-blart EQ gc_re AND
s_doc_ty-LOW EQ gc_re.
APPEND gi_bkpf TO gi_bkpf_re.
ENDIF.
IF gi_bkpf-blart EQ gc_kr AND
s_doc_ty-LOW EQ gc_kr.
APPEND gi_bkpf TO gi_bkpf_kr.
ENDIF.
IF gi_bkpf-blart EQ gc_kg AND
s_doc_ty-LOW EQ gc_kg.
APPEND gi_bkpf TO gi_bkpf_kg.
ENDIF.
ENDLOOP.
endif.
Hope this sort out your issue.
PS Plz close the thread by rewarding each reply.
Regards
Sapna Modi