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

need help

Former Member
0 Likes
1,383

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,348

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

13 REPLIES 13
Read only

Former Member
0 Likes
1,348

well you could write delete from mara where mandt eq sy-mandt.

But it may actaully depened on what you want to do.

Read only

0 Likes
1,348

I need to fill internal table here... how i will do that.

Read only

Former Member
0 Likes
1,349

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

Read only

0 Likes
1,348

yes u r getting me write...

could u give me the sample code for the........

tahnks..

regards.....

Read only

0 Likes
1,348

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

Read only

0 Likes
1,348

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.

Read only

0 Likes
1,348

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.

Read only

0 Likes
1,348

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......

Read only

0 Likes
1,348

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

Read only

0 Likes
1,348

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"

Read only

0 Likes
1,348

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

Read only

0 Likes
1,348

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

Read only

0 Likes
1,348

how i will write select statement for tye given prog...

need help...

thanks...

regards....