‎2007 Jan 19 10:18 AM
There is code given below.... and there is one perform statement "trans_data"
in form statement what i will write. Anybody coulld give the coding..........
Thanks.....
&----
*& Report Z_PR_SER
*&
&----
*&
*&
&----
REPORT z_pr_ser.
TABLES : eban.
*DATA: BEGIN OF ztab1 OCCURS 0.
INCLUDE STRUCTURE zmm_preq_mpur.
*
DATA: END OF ztab1.
*
SELECT * FROM eban INTO TABLE ztab1.
*DATA: itab1 LIKE zmm_preq_mpur OCCURS 0 WITH HEADER LINE.
DATA: itab1 LIKE zservice_structure OCCURS 0 WITH HEADER LINE.
DATA: fm_name TYPE rs38l_fnam.
DATA : item LIKE bapieban OCCURS 0 WITH HEADER LINE.
DATA : serv LIKE bapiesll OCCURS 0 WITH HEADER LINE.
PARAMETERS : p_banfn LIKE eban-banfn OBLIGATORY.
START-OF-SELECTION.
PERFORM get_detail.
PERFORM trans_data.
PERFORM display_smartform.
&----
*& Form display_SMARTFORM
&----
text
----
FORM display_smartform.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_PR_service'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
.
IF sy-subrc <> 0.
WRITE:/ 'ERROR 1'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION fm_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
itab1 = itab1
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "display_SMARTFORM
*----
*Calling FM 'BAPI_REQUISITION_GETDETAIL'
*----
FORM get_detail.
CALL FUNCTION 'BAPI_REQUISITION_GETDETAIL'
EXPORTING
number = p_banfn
ACCOUNT_ASSIGNMENT = ' '
ITEM_TEXTS = ' '
services = 'X'
SERVICE_TEXTS = ' '
TABLES
requisition_items = item
REQUISITION_ACCOUNT_ASSIGNMENT =
REQUISITION_TEXT =
REQUISITION_LIMITS =
REQUISITION_CONTRACT_LIMITS =
requisition_services = serv
REQUISITION_SERVICES_TEXTS =
REQUISITION_SRV_ACCASS_VALUES =
RETURN =
.
ENDFORM. "GET_DETAIL
----
***INCLUDE Z_PR_SER_TRANS_DATAF01 .
----
&----
*& Form trans_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM trans_data .
"what would be the code here"
ENDFORM. " trans_data
‎2007 Jan 19 10:24 AM
Hi Chang ,
What i understand is your program flow is as below
1. Get Data using the BAPI 'BAPI_REQUISITION_GETDETAIL' , into table <b>item</b> and <b>serv</b>.
2. Consolidate the data from the table item and serv into table <b>itab1</b>.
3. Call the smartform <b>'Z_PR_service'</b> passing the table <b>itab1</b>.
Now in your program what is missing is step2 , you need to map the fields of you internal table itab1 with the fields of those tables returend by the BAPI and then populate the table itab1
Regards
Arun
‎2007 Jan 19 10:22 AM
well you could write delete from mara where mandt eq sy-mandt.
But it may actaully depened on what you want to do.
‎2007 Jan 19 10:23 AM
‎2007 Jan 19 10:24 AM
Hi Chang ,
What i understand is your program flow is as below
1. Get Data using the BAPI 'BAPI_REQUISITION_GETDETAIL' , into table <b>item</b> and <b>serv</b>.
2. Consolidate the data from the table item and serv into table <b>itab1</b>.
3. Call the smartform <b>'Z_PR_service'</b> passing the table <b>itab1</b>.
Now in your program what is missing is step2 , you need to map the fields of you internal table itab1 with the fields of those tables returend by the BAPI and then populate the table itab1
Regards
Arun
‎2007 Jan 19 10:25 AM
yes u r getting me write...
could u give me the sample code for the........
tahnks..
regards.....
‎2007 Jan 19 10:30 AM
Hi Chang ,
For that what is very important is the structure of the your internal table itab1.
Just look at the structure of the two table returned by the BAPI and see if there is a similar fields in your internal table also.
Once you identify the mapping , populate the header/workare of the intenal table as below
itab1-field1 = item-field.
......
once all the fields have been populated append the header to the table usin the append command
append itab1.
Regards
Arun
Message was edited by:
Arun R
‎2007 Jan 19 10:45 AM
if u want to fill a final internal table from 2 internal tables then u have to code like this -
Sort itab_vbap by vbeln posnr.
sort itab_vbkd by vbeln posnr.
Loop at itab_vbap into wa_vbap.
read table itab_vbkd into wa_vbkd with key vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr binary search.
if sy-subrc = 0.
move corresponding wa_vbap to wa_final.
move corresponding wa_vbkd to wa_final.
append wa_final to itab_final.
endif.
endloop.
For move corresponding statement the name of the fields should match in both the work areas.
‎2007 Jan 19 10:53 AM
I have this data..
tell me how i will write in perform stratement......
itab1-EXT_LINE = item-EXT_LINE,
itab1-SHORT_TEXT = item-SHORT_TEXT,
itab1-QUANTITY = item-QUANTITY,
itab1-BASE_UOM = item-BASE_UOM,
itab1-PRICE_UNIT = item-PRICE_UNIT,
itab1-DELIV_DATE = item-DELIV_DATE,
itab1-MATL_GROUP = item-MATL_GROUP,
itab1-PLANT = item-PLANT,
itab1-PREQ_NO = item-PREQ_NO,
itab1-DES_VENDOR = item-DES_VENDOR,
itab1-FIXED_VEND = item-FIXED_VEND.
‎2007 Jan 19 10:55 AM
In have this data in in my bapi.....
itab1-EXT_LINE = item-EXT_LINE,
itab1-SHORT_TEXT = item-SHORT_TEXT,
itab1-QUANTITY = item-QUANTITY,
itab1-BASE_UOM = item-BASE_UOM,
itab1-PRICE_UNIT = item-PRICE_UNIT,
itab1-DELIV_DATE = item-DELIV_DATE,
itab1-MATL_GROUP = item-MATL_GROUP,
itab1-PLANT = item-PLANT,
itab1-PREQ_NO = item-PREQ_NO,
itab1-DES_VENDOR = item-DES_VENDOR,
itab1-FIXED_VEND = item-FIXED_VEND.
now twll me hw I will write the code......
‎2007 Jan 19 11:02 AM
Hi Chang ,
A simple solution is to declare the varaibles itab1 , item as global variables , if feel this is already the case.
So what you can do is
Loop at item .
perform append_line.
endloop.once you write thic double click on append_line , the framework of the surboutine is automatically created.
form append_line.
*"Now write this code in the framework
itab1-EXT_LINE = item-EXT_LINE,
itab1-SHORT_TEXT = item-SHORT_TEXT,
itab1-QUANTITY = item-QUANTITY,
itab1-BASE_UOM = item-BASE_UOM,
itab1-PRICE_UNIT = item-PRICE_UNIT,
itab1-DELIV_DATE = item-DELIV_DATE,
itab1-MATL_GROUP = item-MATL_GROUP,
itab1-PLANT = item-PLANT,
itab1-PREQ_NO = item-PREQ_NO,
itab1-DES_VENDOR = item-DES_VENDOR,
itab1-FIXED_VEND = item-FIXED_VEND
append itab1. " add this
clear itab1. " add this
endform.but i feel you dont need a sburoutine , you can very well write this code in the loop itself.
Feel free to revert back in case you have any further queries
Regards
Arun
‎2007 Jan 19 11:13 AM
Hi arun,
I need to ask one thing that as i took data from ITEM and SERV of BAPI and created one structure named "zservice_structure".
Finally data resides in this structure.
Now tell what would be the exact coding.......in "Perfrom_trans"
‎2007 Jan 19 12:19 PM
Hi ,
Could you please tell me the structue of the internal tabla itab 1, as this will makes things a little simpler for me.
Regards
Arun
‎2007 Jan 22 2:07 PM
Hi arun ...
this is my prog......
Hw I will write select statement for that...
pz do let me know....
Thanks......
&----
*& Report Z_PR_SER
*&
&----
*&
*&
&----
REPORT z_pr_ser.
TABLES : eban.
*DATA: BEGIN OF ztab1 OCCURS 0.
INCLUDE STRUCTURE zmm_preq_mpur.
*
DATA: END OF ztab1.
*
SELECT * FROM eban INTO TABLE ztab1.
*DATA: itab1 LIKE zmm_preq_mpur OCCURS 0 WITH HEADER LINE.
DATA: itab1 LIKE zservice_structure OCCURS 0 WITH HEADER LINE.
DATA: fm_name TYPE rs38l_fnam.
DATA : item LIKE bapieban OCCURS 0 WITH HEADER LINE.
DATA : serv LIKE bapiesll OCCURS 0 WITH HEADER LINE.
PARAMETERS : p_banfn LIKE eban-banfn OBLIGATORY.
START-OF-SELECTION.
PERFORM get_detail.
PERFORM trans_data.
PERFORM display_smartform.
&----
*& Form display_SMARTFORM
&----
text
----
FORM display_smartform.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_PR_SERVICE'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
.
IF sy-subrc <> 0.
WRITE:/ 'ERROR 1'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION fm_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
itab1 = itab1
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "display_SMARTFORM
*----
*Calling FM 'BAPI_REQUISITION_GETDETAIL'
*----
FORM get_detail.
CALL FUNCTION 'BAPI_REQUISITION_GETDETAIL'
EXPORTING
number = p_banfn
ACCOUNT_ASSIGNMENT = ' '
ITEM_TEXTS = ' '
services = 'X'
SERVICE_TEXTS = ' '
TABLES
requisition_items = item
REQUISITION_ACCOUNT_ASSIGNMENT =
REQUISITION_TEXT =
REQUISITION_LIMITS =
REQUISITION_CONTRACT_LIMITS =
requisition_services = serv
REQUISITION_SERVICES_TEXTS =
REQUISITION_SRV_ACCASS_VALUES =
RETURN =
.
ENDFORM. "GET_DETAIL
----
***INCLUDE Z_PR_SER_TRANS_DATAF01 .
----
&----
*& Form trans_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM trans_data .
*
loop at item.
loop at serv where PCKG_NO = item-PCKG_NO and
OUTL_IND = ' '.
itab1-EXT_LINE = serv-EXT_LINE.
itab1-SERVICE = serv-SERVICE.
itab1-SHORT_TEXT = item-SHORT_TEXT.
itab1-QUANTITY = item-QUANTITY.
itab1-BASE_UOM = serv-BASE_UOM.
itab1-PRICE_UNIT = item-PRICE_UNIT.
itab1-DELIV_DATE = item-DELIV_DATE.
itab1-MATL_GROUP = serv-MATL_GROUP.
itab1-PLANT = item-PLANT.
itab1-PREQ_NO = item-PREQ_NO.
itab1-DES_VENDOR = item-DES_VENDOR.
itab1-FIXED_VEND = item-FIXED_VEND.
append itab1.
endloop.
clear itab1.
endloop.
ENDFORM. " trans_data
*&----
**& Form append_line
*&----
text
*----
--> p1 text
<-- p2 text
*----
*form append_line .
*
*itab1-SHORT_TEXT = item-SHORT_TEXT.
*itab1-QUANTITY = item-QUANTITY.
*itab1-PRICE_UNIT = item-PRICE_UNIT.
*itab1-DELIV_DATE = item-DELIV_DATE.
*itab1-PLANT = item-PLANT.
*itab1-PREQ_NO = item-PREQ_NO.
*itab1-DES_VENDOR = item-DES_VENDOR.
*itab1-FIXED_VEND = item-FIXED_VEND.
*
*append itab1.
*clear itab1.
*endform. " append_line
‎2007 Jan 22 2:21 PM
how i will write select statement for tye given prog...
need help...
thanks...
regards....